ctx.shared
One value, one link. The owner makes it; anyone with the link reads it — signed out, or without your app; and if the owner says so, signed-in people write to it. For a note, a list or a board that one person starts and others join.
Calls
const row = await ctx.shared.create(value, { edit: false }); // → { id, key, ref, value, v, edit, mine, owner, editor, updatedAt } const link = `https://my-app.fave1.app/#s=${row.ref}`; // ref is "id.key" — the link is the secret const got = await ctx.shared.get(ref); // the row, or null when it's gone — works signed out const { v } = await ctx.shared.set(ref, value, { base: got.v }); // write; base guards against lost edits await ctx.shared.access(row.id, { edit: true }); // owner only — let people with the link write await ctx.shared.list(); // this person's links from your app — { id, key, ref, v, edit, bytes, edited, updatedAt, mine, owner } — no value: get(ref) one to read it await ctx.shared.delete(row.id); // owner only — the link stops working for everyone
Declared with storage — no new permission. A value is JSON up to 64 KB, one person shares up to 100 per app, and they count toward the owner’s Fave1 storage. The owner’s calls (create · access · list · delete) follow ctx.storage’s rules: a signed-in person who added your app, one OK on a new site, never in app mode. get() is the odd one out — it works for anyone who has the link.
Where it sits
Pick by who should see it. A note for one friend is shared. A board for everyone is pub. Two people typing on the same thing right now is live — shared is not pushed; readers ask for it (Keeping it fresh).
What a row looks like
{
id: 'k3f9q2m8x1pz', // 12 characters — names the value; the owner uses it for access() and delete()
key: 'qw8rt2yu6io0pa4sd7fg9h', // 22 lowercase letters and digits — unlocks it
ref: 'k3f9q2m8x1pz.qw8rt2yu6io0pa4sd7fg9h', // id.key — what goes in the link, and back into get() · set()
value: { title: 'Packing list', items: [/* … */] },
v: 7, // changes with every write — pass it as base to set()
edit: true, // can people with the link write?
updatedAt: '2026-10-26T09:41:12.000Z',
mine: false, // did this person make it?
owner: { initial: 'M', color: 'linear-gradient(…)', avatar: 'data:image/svg+xml,…', avatarStill: 'data:image/svg+xml,…' }, // who made it — a letter, a color and their avatar, never a name
editor: { initial: 'J', color: 'linear-gradient(…)', avatar: 'data:image/svg+xml,…', avatarStill: 'data:image/svg+xml,…' }, // who wrote last, if someone other than the owner did — else null
}mine is how app mode knows whether to draw the owner’s controls (Stop sharing, Let people edit) or the reader’s (Keep a copy). owner and editor are a first letter, an avatar color and the avatar they picked each — enough for “Shared by M · edited by J”, and never a name. v is a counter, not a time: compare it to the v you last saw to know whether anything changed.
The link is the secret
ref is id.key: twelve characters that name the value and twenty-two that unlock it. Put it in a URL your app opens with — #s=<ref> in app mode is the pattern Fave1’s own apps use, and a hash never reaches any server — and read it back with get(). Anyone who has the link has the value; there is no list of who. Don’t post a ref anywhere public from your code, and let the owner take it back with delete().
get() works for everyone — signed out, or someone who never added your app — because the key is the door. It resolves null when the key is wrong or the owner took it back — the two look the same on purpose — and rejects with invalid only when what you pass isn’t shaped like id.key at all. It still needs storage in your manifest, and a signed-in reader who switched storage off for your app gets denied like any other storage call. Reads are counted per network address — a page that polls a link in a tight loop gets rate.
Links don’t expire on their own. They stop when the owner deletes them, removes your app, clears your app in Fave1 Settings › Storage, or deletes their account.
A note, start to finish
The shape that holds up: the owner keeps the note in ctx.storage as before, and sharing adds a link next to it. Every save goes to both. Readers open the link in app mode.
type Note = { title: string; body: string }; // 1. Share — once, when the owner presses Share. Keep the link next to the note. const note = (await ctx.storage.get('note:abc')) as Note | undefined; if (!note) return; const row = await ctx.shared.create<Note>(note, { edit: false }); await ctx.storage.set('note:abc:link', { id: row.id, ref: row.ref }); const link = `https://my-app.fave1.app/#s=${row.ref}`; // show it, copy it, hand it to navigator.share // 2. Save — every time the owner edits. Their copy first, then the link. async function saveNote(next: Note) { await ctx.storage.set('note:abc', next); await ctx.shared.set(row.ref, next); // no base: the owner overwrites — nobody else can edit this one } // 3. Stop sharing — the link goes dead for everyone; the note stays in ctx.storage. async function stopSharing() { await ctx.shared.delete(row.id); await ctx.storage.delete('note:abc:link'); }
type Note = { title: string; body: string }; // A link opens straight to the shared note — signed in or not. if (ctx.surface === 'app' && location.hash.startsWith('#s=')) { const ref = location.hash.slice(3); const got = await ctx.shared.get<Note>(ref); if (!got) { ctx.ui.render([ctx.ui.text('This link isn’t live any more.')]); return; } showNote(got.value, { mine: got.mine, canEdit: got.edit && ctx.user.signedIn, by: got.owner }); // "Keep a copy" — into this reader's own storage, with the ref so you can pull updates later. if (!got.mine && ctx.can('storage')) { ctx.ui.render([ctx.ui.button('Keep in my notes', { onClick: () => ctx.storage.set(`kept:${got.id}`, { ref, note: got.value, v: got.v }), })]); } }
Signed-out readers see the note and nothing else — ctx.can('storage') is false, so there’s no Keep and no editing. Say so instead of hiding it: a line like Sign in to keep this turns a reader into an account.
Letting people write
With edit on, any signed-in person with the link can call set(). Off (the default), only the owner can; others get denied. Someone signed out gets signed-out. On a site that hasn’t said yes to your app, the first write from a non-owner asks once, like storage does; in app mode it never asks. The owner flips it any time with access(id, { edit }) — turning it off doesn’t undo what was written.
type Item = { id: string; text: string; done: boolean }; type List = { items: Item[] }; // Save what this person changed, without losing what someone else saved in between. async function saveList(ref: string, mine: List, base: number): Promise<number> { try { return (await ctx.shared.set(ref, mine, { base })).v; } catch (err) { const e = err as Fave1Error; if (e.code !== 'conflict' || !e.current) throw err; const theirs = e.current.value as List; const byId = new Map<string, Item>(theirs.items.map((it) => [it.id, it])); for (const it of mine.items) byId.set(it.id, it); // mine win per item; theirs stay where I never touched const merged: List = { items: [...byId.values()] }; return (await ctx.shared.set(ref, merged, { base: e.current.v })).v; } }
Always pass base — the v you read. If someone wrote in between, set() rejects with conflict and err.current is the row as it is now; merge and write again with its v. The merge is yours to write because only your app knows its shape — a list merges by item, a note by paragraph, a counter by taking the larger. Without base it overwrites, which is right only for the owner pushing a value nobody else can edit.
Keeping it fresh
Nothing is pushed. A reader sees what get() returned, until you call it again. Ask when it matters — when the tab comes back, and every few seconds while they are looking — and redraw only if v moved. The owner does the same for a link with edit on, so their own copy picks up what others wrote.
type Note = { title: string; body: string }; const ref = location.hash.slice(3); const got = await ctx.shared.get<Note>(ref); if (!got) return; let seen = got.v; async function refresh() { const now = await ctx.shared.get<Note>(ref); if (!now) { ctx.ui.toast('The owner stopped sharing this.', 'error'); return; } if (now.v === seen) return; seen = now.v; showNote(now.value, { by: now.editor ?? now.owner }); } const onShow = () => { if (!document.hidden) refresh(); }; document.addEventListener('visibilitychange', onShow); const timer = setInterval(refresh, 12000); // In onDestroy: clearInterval(timer); document.removeEventListener('visibilitychange', onShow);
Twelve seconds is plenty for a note or a list; reads are cheap but counted. Stop the timer and remove the listener in onDestroy — on a site, document is the page’s and outlives your app — and don’t poll from the page surface while the panel is minimized — nobody is looking.
Limits and errors
Per value
Measured as JSON text — the same cap as a storage value. Over it, too-large before anything leaves the page.
Per person, per app
Links one person has open at once. The 101st create() fails with quota, scope 'shared' — let them delete one.
Counted
Shared values live on the owner’s Fave1 storage, next to app data and files — a full account can still read and delete.
Reads
get() is open to the world, so it is rate-limited per network address. Poll gently.
set() with a stale base — err.current.value and err.current.v are the row now; merge with those two onlymerge, set againedit is off — or storage isn’t in your manifest, or they switched it offctx.perms.open()set() · access() on a link that’s gone or isn’t theirs. get() gives null instead, and delete() resolves anywaysay soget() needs an accountfold the featureget() still workssay soerr.scope 'shared' — 100 links already; 'account' — their Fave1 storage is fulldelete() · ctx.files.manage()id.key), or a value that isn’t JSONfix itWhen the owner removes your app or deletes their account, their shared values go too. They can also clear everything your app keeps — shared values included — in Fave1 Settings › Storage; a reader then gets null, the same as a deleted link.
While you build
create(), get() and set() all work, and conflict shows up as it would for real. A link you make there opens in this browser only. Switch Data to My account to make a real link, then open it in another browser (or signed out) to see the reader’s side.