ctx.storage
Private JSON on this person’s Fave1 account, per key. Nobody else reads it — not other apps, not other people. It follows them to every site and to your app in app mode.
Calls
await ctx.storage.get(key); // the value, or undefined await ctx.storage.set(key, value); // any JSON value but null, up to 64 KB — delete() clears a key await ctx.storage.delete(key); await ctx.storage.list(); // the keys, sorted await ctx.storage.usage(); // { bytes, limit } — how full your app’s share is await ctx.storage.prefs.get(); // a small settings object — never asks await ctx.storage.prefs.set(obj); // up to 2 KB, readable on any page your app opens on await ctx.storage.append(key, item); // add one row to a list — asks once for your app, not per site await ctx.storage.askAppend(); // ask for that one yes now — true once it's given await ctx.storage.forgetAppend(); // the next append() on a site asks again
It lives on the account
What someone saves on etsy.com is there when your app opens on amazon.com, and on the app’s own page at <id>.fave1.app — one account, one store per app. That is what makes app mode possible: notes from every site, one list.
Nobody signed in means nowhere to save. ctx.can('storage') is false then — fold the feature and keep the rest of the app working.
Not even you can read it. There’s no developer view of what people save — your code reads it on their device, with their session.
The first use on a site
The first time your app touches the account from a site — even just reading — Fave1 asks once, in your panel: Use your Fave1 account here? The button is Fave1’s own, so a page can’t press it and can’t read anyone’s notes. Every call after that on that site goes straight through, and the same answer covers ctx.files and ctx.pub. In app mode it never asks. To know before you call, check ctx.user.granted. Settings you want everywhere from the first second — a pen color, a switch — go in prefs, which never asks.
So the first call can take as long as a person takes to decide, and can reject with cancelled. Treat that as a normal answer.
To let one person hand a value to others by link — a note, a list — see ctx.shared; it rides on the same permission.
Settings that never ask
prefs is one small object per app for settings — the pen color, a switch someone flipped, the last tab. It never asks, on any site, so your app can open with the person’s own settings everywhere, even on a site where they haven’t said yes yet.
// Open with what this browser remembers, then catch up with the account. let prefs = JSON.parse(localStorage.getItem('my-app.prefs') || '{}'); const saved = ctx.can('storage') ? await ctx.storage.prefs.get() : null; // null if none or signed out if (saved && (saved.t ?? 0) > (prefs.t ?? 0)) prefs = saved; // Someone flips a switch: prefs = { ...prefs, compact: true, t: Date.now() }; localStorage.setItem('my-app.prefs', JSON.stringify(prefs)); await ctx.storage.prefs.set(prefs);
get · set.get · set, where only a site the person said yes to can write. If you show them on every site from the first second, keep a copy in prefs for display and treat the private key as the real one.set(null) clears it.too-large · invalidset() since — a change from another tab or site shows up next time your app opens. null before the first set, when nobody is signed in, when storage was switched off in Settings, or when Fave1 couldn’t be reached — never a prompt, never a wait for a tap. Rejects when storage isn’t declared, or when your app opened with it already switched off — check ctx.can('storage') firstdeniedClearing your app in Fave1 Settings › Storage clears prefs too, and removing the app deletes it. A DEV build keeps it in this browser.
A history from every site
Some apps fill one list from wherever they’re used — a share history, a reading log, a list of things you sent. Asking on every new site would wear people out, so append() asks once for your app: Keep your history in <app>? It can only add a row to the end of a list. It returns nothing and reads nothing, which is why one yes is safe for every site. Reading the list, editing it and deleting rows are ordinary get · set · delete — in app mode they never ask.
// When your panel opens on a site — ask now, while they're looking at it: const keep = await ctx.storage.askAppend({ what: 'share history' }).catch(() => false); // Each time someone sends something: if (keep) await ctx.storage.append('sent:2026-11', { url: location.href, to: 'x' }, { what: 'share history' }); // In app mode — read it back. Each row is { at, site, item }. const rows = (await ctx.storage.get('sent:2026-11')) as { at: string; site: string | null; item: { url: string } }[] | undefined; for (const r of rows ?? []) console.log(r.at, r.site, r.item.url); // Someone turns the history off: await ctx.storage.forgetAppend();
Ask with askAppend() when your panel opens, not inside the click that opens another window — the question shows up on the page they just left and nobody sees it. It returns true at once when the yes is already there (and always in app mode), false when they say not now, and rejects with cancelled if your panel closes before they answer. It asks about the history itself — even on a site that already allowed your app, where append() would go straight through — so call it once, when your history feature first matters.
Fave1 writes at (its own clock) and site (the host of the page the row came from — null in app mode, 'local' for a file opened from their computer). Your code can’t set either. Because anyone’s page can add a row once the person said yes, check that a row’s link matches its site before you trust it.
null.too-large · invalidaskAppend(), or on the first append() on a site. opts.what names it in the prompt — up to 24 letters and spaces; anything else falls back to the default history. Turning storage off in Settings, or forgetAppend(), takes it back. A site that already allowed your app never asks.cancelledPatterns that hold up
One key
settings → { theme, sort } when the whole thing is small and always read together.
A key per item
note:<id> plus an index array when the list grows. Don’t rewrite a big blob on every save.
Limits
usage() tells you theirs. Plan for 1 MB: keep records small, and put files in ctx.files.quota · appHow full it is
usage() says where your app stands for this person. bytes is what your app keeps on their account, counted the way set() counts it — each value as JSON text. limit is your app’s share on their plan. Ask instead of writing 1 MB into your code: the share depends on their plan, and plans change.
const { bytes, limit } = await ctx.storage.usage(); if (bytes > limit * 0.9) { // Almost full — drop the oldest entries now, before a save fails. }
Or show it, so people know where they stand:
const size = (n: number) => n < 1024 * 1024 ? `${Math.round(n / 1024)} KB` : `${+(n / 1024 / 1024).toFixed(1)} MB`; const { bytes, limit } = await ctx.storage.usage(); ctx.ui.render([ctx.ui.text(`${size(bytes)} of ${size(limit)}`)]); // 412 KB of 1 MB
Files don’t count here — they go to the person’s Fave1 storage, which you handle with quota (scope 'account') and ctx.files.manage(). And it only speaks for your app: not other apps, not their whole storage, not their plan.
Same rules as list(): it needs a signed-in person, asks once on a new site, and never asks in app mode. A DEV build reports this browser’s sandbox and 1 MB.
When it’s full
A quota error says which limit with err.scope. 'app' — your app’s own share is full: 1 MB on Free, 10 MB on paid plans. Let them delete something in your app first; on Free, a paid plan also lifts the share to 10 MB, and ctx.files.manage() opens their storage. 'account' — their Fave1 storage is full, or their app data across every app is: offer ctx.files.manage(), where they can clear it. An older runtime may leave the scope out; read that as 'account'.
try {
await ctx.storage.set(`note:${id}`, note);
} catch (err) {
const e = err as Fave1Error;
if (e.code !== 'quota') throw err;
if (e.scope === 'app') {
// Your app's own share is full — make room in your app first.
ctx.ui.toast('Too many notes. Delete a few to keep going.', 'error');
} else {
// Their Fave1 storage is full.
ctx.ui.render([
ctx.ui.text('Your Fave1 storage is full.'),
ctx.ui.button('Make room', { onClick: () => ctx.files.manage() }),
]);
}
}A write that’s the same size or smaller always goes through, even over a limit — someone who’s full can still trim a record or drop an item from an index. Deleting always works.
They can clear it
People see what each app keeps in Fave1 Settings › Storage and can delete it whenever they like — your app isn’t told. A key you saved can come back undefined, your index included, and a shared link they cleared answers null from then on. Treat that like a first run, not an error.
Errors
storage isn’t in your manifest, or they switched it offctx.perms.open()append() to a key that isn’t a listfix itWithout the permission
Undeclared, or switched off in settings — every call rejects with a typed denied error. Check ctx.can('storage') and fold the feature; Permissions has the full contract. The same switch covers ctx.files, ctx.shared and ctx.stickers. Switching it off keeps the data, files and links; removing the app deletes them.
While you build
fave1 dev or a review link, ctx.storage keeps values in this browser, on this site — nothing touches your real account, unless you switch Data to My account. The sandbox holds your app to 1 MB — the Free share, the one to design for — so quota with scope 'app' shows up as it would for real.To try a full account, give the sandbox a size. Everything it holds on that site, files included, counts against it — past that, saves reject with quota, scope 'account'.
localStorage.setItem('fave1.dev.quota', '200000'); // bytes localStorage.removeItem('fave1.dev.quota'); // back to no account limit