docs / Concepts
get started

One app. Two modes.

You don’t build a bookmarklet app and an OS app. You build one bundle. The shell decides which mode it runs in — card mode or app mode.

card mode

A card on someone’s site

Etsy, eBay, articles — opened from the bookmarklet, a Fave1 Button or Try it. ctx.page is that live document. Break the Site lives here.

app mode

<id>.fave1.app

Opened from My Fave1. Same install, same session. ctx.page is your own page — never fave1.com.

The panel and the page

ctx.ui

The panel — blocks or your own DOM

Blocks for lists and forms; host() for an editor, a gallery, a board. The header is always Fave1’s — no app can fake it.

ctx.page

The host page — full DOM

The real document. Query, mutate, animate. That’s the product.

Which mode am I in?

src/index.ts
if (ctx.surface === 'card') {
  // Card mode — a card on someone's site. Play with the page.
} else {
  // 'app' — app mode, your own screen at <id>.fave1.app. Boards, lists, settings.
}

ctx.surface is how one bundle draws two screens — the game in card mode, the board in app mode. It never changes mid-run: opening the other mode is a fresh launch.

One wall

Reshape the host page all you like. You can’t touch the session, another app’s data, or the shell. Everything outside the page goes through ctx, and ctx only has what your manifest declared. The browser itself is yours too, with a few rules — Beyond ctx.

Everything on ctx

MemberWhat it isNeeds
ctx.uiThe panel — blocks, your own DOM, moving it out of the way. ctx.ui—
ctx.pageThe page you opened on — its address and title always, its text or whole DOM if declared. ctx.pagepage.*
ctx.storagePrivate JSON on the person’s account. ctx.storagestorage
ctx.filesTheir files on the account. ctx.filesstorage
ctx.sharedA value shared by one link — anyone with it reads, and edits if the owner lets them. ctx.sharedstorage
ctx.stickersGive them a sticker for their My Fave1 home — a reward they choose where to put. ctx.stickersstorage
ctx.purchasesSell things inside your app for Fave1 credits — Fave1 holds the price and the Buy button. Not open to your app yet. ctx.purchasesstorage
ctx.pubOne public value per person, readable by everyone using your app. ctx.pubpub
ctx.liveRooms — several people edit the same table at once, pushed live — and direct lines between two of them. ctx.livepub
ctx.userSigned in or not, an id that’s yours alone, whether the account opens without asking, and their plan (plus · tier). ctx.user—
ctx.configA JSON you edit in the console. ctx.config—
ctx.locale · ctx.t(key)The language this person uses, and your words in it from locales/*.json — English underneath. ctx.locale · ctx.t—
ctx.notify.send() · cancel() · status() · on() · openedA notification to this person, from your app — a reminder they set — or to someone else for what was done for them. A number on your icon and a row in their Fave1 notifications; on() fires while your app is open. ctx.notify—
ctx.surface'card' in card mode, 'app' in app mode — above—
ctx.can(p)Is this permission live right now — declared, switched on, and for storage · pub (so also ctx.files · ctx.shared · ctx.live), someone signed in. When one is off—
ctx.perms.open()Opens your app’s permission screen in their Fave1 settings, in a new tab—
ctx.clipboard.read() · write(t)Copy and paste — pasting asks every time. See ctx.clipboardclipboard
ctx.ai.chat() · stream() · run() · speak() · status() · choices() · setup()Ask an AI model on Fave1 AI — Claude, ChatGPT, Gemini or Grok, paid from the person’s Fave1 credits — text, pictures, answers in a shape, tools, a voice that reads it out (voices()), and what’s left this month (usage()). No keys anywhere. See ctx.aiai
ctx.camera.open() · close()Their camera, live, while your app is open — Fave1 asks first and shows a red dot. See ctx.cameracamera
ctx.mic.open() · close()Their microphone, live, while your app is open — Fave1 asks first and shows a red dot. See ctx.micmic

Every call that can fail rejects with an Error carrying a code — denied, signed-out, quota and so on, typed as Fave1Error in types/fave1.d.ts. Each page lists the codes it can give.

Lifecycle

src/index.ts
Fave1.defineApp({
  onLaunch(ctx) {
    // The panel opened. Draw it, read the page, change the page.
  },
  onDestroy() {
    // The panel closed. Put the page back, stop your timers.
  },
});

Two hooks, that’s all. onLaunch runs each time someone opens your app; onDestroy runs when they close it or open another one, and gets the same ctx. Your bundle itself runs once per page: close the app and open it again on the same page, and module variables still hold what they held. So set up your state in onLaunch and clear it in onDestroy. DEV builds load fresh on every open, so you won’t see leftovers while you build — people will. What should outlast the page goes in ctx.storage.