Save form data from HTML without a backend: Page data
A page you publish on BrewPage can keep what its visitors enter: form answers, guestbook messages, votes, quiz results, game progress. The page loads one script. There is no server to run and no key in the code. Need to check a save or act on it? Add server code with Brew Lambda. This guide shows the code, how to test it on your computer and how the templates use it.
pages have already saved what their visitors enter
Start from a templateWhat you can make
Forms and polls
Made with AI
Instead of an app
Save form data from HTML without a backend
- 1The page loads
https://brewpage.app/js/state.jsand callsbp.state()to save and read entries. - 2You publish it with a
statefield that names the lists it keeps. The page gets its own address, where saving works. - 3Visitors save. You read every entry in the page's Data tab, as CSV or through the API.
Each visitor reads and writes their own entries. A list you make shared is read by everyone, and you can make a list that only you write: who reads and writes.
Page data is for what visitors type into a published page. To publish data yourself from a script or an agent, use JSON documents or a key-value store with the owner token instead.
Quick start
1. Load the script with this exact tag, before your own code:
<script src="https://brewpage.app/js/state.js"></script>
2. Write the page. This one asks one question, keeps each visitor's answer and shows it again on return:
page.html
<!DOCTYPE html>
<meta charset="utf-8">
<title>One question</title>
<form id="ask">
<input name="answer" required placeholder="Your answer">
<button id="send" disabled>Send</button>
</form>
<p id="note"></p>
<p>What you enter is saved on BrewPage and can be read by this page's author.</p>
<script src="https://brewpage.app/js/state.js"></script>
<script>
async function start() {
const form = document.getElementById("ask");
const note = document.getElementById("note");
const s = await bp.state();
if (!s) { form.hidden = true; note.textContent = "Saving is not available on this page right now."; return; }
const answers = s.col("answers");
const mine = await answers.get("me");
if (mine) form.elements.answer.value = String(mine.answer);
document.getElementById("send").disabled = false;
form.addEventListener("submit", async (e) => {
e.preventDefault();
try {
await answers.set("me", { answer: form.elements.answer.value });
note.textContent = "Saved.";
} catch (err) {
note.textContent = err.message;
}
});
}
start();
</script>
Open the file in your browser to try it before publishing: see local preview.
3. Publish it with a JSON body that carries state. {} is enough here: every list is then each visitor's own. A raw HTML body cannot carry state.
Publish page.html with page data on
jq -n --rawfile html page.html '{content: $html, format: "html", state: {}}' \
| curl -X POST https://brewpage.app/api/html \
-H "Content-Type: application/json" \
--data-binary @-
The JSON answer holds two links. link is the page to share, on its own address such as https://abc123.brewpage.app. manageUrl is the management link: keep it private, it opens the page's settings and the Data tab with what visitors saved. Keep ownerToken too if you update the page through the API.
Rather use the browser? Paste the page at brewpage.app and turn on Page data in the editor's options. Every state option: API → Say what the page saves.
API by task
Find what your page needs, declare the list as shown, then use the calls. Full signatures and answers: API → Load the script.
| Task | List rule in state | Calls | See |
|---|---|---|---|
| One answer per visitor: a form, a sign-up, a quiz | None needed: lists are each visitor's own | c.set("me", value), c.get("me") | Simple form, advanced form, quiz |
| Count choices for everyone: a poll, an RSVP, a rating | choices with the allowed values of a field | c.set("me", value), c.stats({countBy}) | Poll, RSVP, feedback |
| A list everyone reads: a guestbook, who brings what | "mode": "shared", often with maxDocsPerVisitor | c.add(value), c.list({order, limit}), c.remove(key) | Guestbook, bring list |
| One order everyone shares: a backlog, a ranking | "mode": "shared" with "maxDocsPerVisitor": 1 | c.set("me", value), c.list({order: "-updatedAt", limit}) | Product backlog |
| Save progress: a game, a draft, settings | None needed | c.set(key, value), c.get(key); or bp.storage like localStorage | Clicker game |
| Top scores | "mode": "shared" with index on the score field | c.set("best", value), c.list({order: "-index"}) | API: list rules |
| Content only you write: a menu, a schedule | "mode": "shared" with "write": "author" | Visitors: c.list(); you write through the author API | API: author API |
| Take files: photos, a résumé, a CSV | "files": true | c.files, c.upload(file), c.removeFile(id) | Files from visitors, job application |
| Show every entry to you on the page | None needed | s.onRole(fn), c.list({all: true}), c.removeById(id) | Owner view |
| Show an entry safely | Any | bp.text(value) or textContent, never innerHTML | Every template |
Here s is what await bp.state() returns and c is s.col("name"), one list. Save on change or submit, not on every keystroke.
Progress without lists: bp.storage works like localStorage and keeps one entry per visitor, with "state": {}. It batches writes by itself:
Game level with bp.storage
<p>Level <span id="level">1</span> <button id="next">Next level</button></p>
<p>What you enter is saved on BrewPage and can be read by this page's author.</p>
<script src="https://brewpage.app/js/state.js"></script>
<script>
async function start() {
const out = document.getElementById("level");
await bp.storage.ready;
let level = Number(bp.storage.getItem("level")) || 1;
out.textContent = level;
document.getElementById("next").addEventListener("click", () => {
level += 1;
out.textContent = level;
bp.storage.setItem("level", String(level));
});
}
start();
</script>
The templates, line by line
Each template is one working HTML file. Open one, try it and press Publish my copy, or read its whole source at https://brewpage.app/templates/<name>/source. The lines below are copied from the sources and show the part that saves.
Every template starts the same way
For developers: how every template starts
The save buttons stay disabled until bp.state() answers. With null the page keeps working and says why nothing is saved. From the guestbook:
templates/guestbook.html
async function start() {
if (!window.bp) return showNote(OFF);
const s = await bp.state();
if (!s) return bp.state.reason === "embedded" ? showNote("Open this page in its own tab to save.", true) : showNote(OFF);
book = s.col("guestbook");
if (book.onStats) { book.onStats({}, paint); live = true; } else await showCount();
$("sign").disabled = false;
await show();
if (s.onRole) s.onRole((r) => { const own = r === "owner"; $("owner-strip").hidden = $("owner-box").hidden = !own; if (own) showOwner(); });
}
Shared lists: guestbooks, bring list, product backlog and riddle lock
Guestbook. Visitors sign with a name and a message, and everyone reads the wall. Try it live
For developers: how it saves
- State: Its
state:{"collections":{"guestbook":{"mode":"shared","maxDocsPerVisitor":5}}}. - Visitor calls: It saves with
book.add({ name, text })and shows the wall withbp.text, so a message is never run as markup;d.minemarks the visitor's own entries. - Totals: The count of all messages moves live for everyone:
book.onStats({}, paint).
templates/guestbook.html
for (const d of docs) {
const li = document.createElement("li");
if (d.mine) li.className = "mine";
const v = d.value || {};
const who = document.createElement("span"); who.className = "who"; who.append(bp.text(v.name));
const meta = document.createElement("span"); meta.className = "meta"; meta.textContent = ago(d.createdAt) + (d.mine ? " · you" : "");
li.append(who, bp.text(v.text), meta);
wall.append(li);
Wedding guest book. Guests sign with their name and a wish; each wish lands on the wall as a card, and the couple reads every one. Try it live
For developers: how it saves
- State: Its
state:{"collections":{"wishes":{"mode":"shared","maxDocsPerVisitor":5}}}. The template page useswedding-guestbook.demo.json, the same list in private mode, so the demo shows only your own wishes. - Visitor calls: The same calls as the guestbook:
book.add({ name, text }), the wall drawn withbp.text, the count live withbook.onStats({}, paint).
Bring list. Who brings what: names appear beside the items, and visitors can take back their own. Try it live
For developers: how it saves
- State: Its
state:{"collections":{"items":{"mode":"shared","maxDocsPerVisitor":5,"choices":{"item":["Salad","Bread","Drinks","Fruit","Dessert","Plates and cups"]}}}}. - Visitor calls: It reads the whole list with
items.list({ order: "createdAt", limit: 100 }), and when a visitor has no room left,addrejects witherr.code === "quota"and the page says so. Everyone sees how many bring each item:items.onStats({ countBy: "item" }, paint). Taking an item back removes the visitor's own entry by its key:
templates/bring-list.html
async function drop(d, what, btn) {
btn.disabled = true; status.textContent = "Removing..."; busy = true;
try {
await items.remove(d.key);
status.textContent = what + " is off your list.";
await show();
Product backlog. A team drags task cards into one shared order; everyone sees the newest order and who moved what. Try it live
For developers: how it saves
- State: Its
state:{"maxDocBytes":1024,"collections":{"moves":{"mode":"shared","maxDocsPerVisitor":1,"choices":{"tick":["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31"]}}}}: one entry per visitor, nothing typed. - Visitor calls: The board is the newest entry, read with
moves.list({ order: "-updatedAt", limit: 5 }); every order passesclean(), so it only ever holds the page's own tasks. A visitor saves withmoves.set("me", value), and each save sets a newtick, somoves.onStats({ countBy: "tick" }, stats)tells the other open pages to read the board again. A move reads the newest board first and lands on top of it:
templates/product-backlog.html
async function save(id, at, el) {
saving = true; pend = false; say("Saving...");
let base = last;
try {
const docs = await newest(), n = docs[0];
base = clean(n && val(n).order);
const from = base.indexOf(id), o = put(base, id, at(base)), to = o.indexOf(id);
if (to === from) { paint(base, {}); return say("“" + T[id] + "” is already #" + (to + 1) + "."); }
paint(o, {});
let t; do t = String(Math.floor(Math.random() * 32)); while (t === tick);
Riddle lock. Visitors type an answer and press Unlock; the page's server code (Brew Lambda) checks it, so the answer is never in the page, and records each solve. Try it live
For developers: how it saves
- State: Its
state:{"collections":{"solves":{"mode":"shared","write":"author"}}}: visitors read the list, only the page's server code writes it. - Server code: On Unlock the page calls
bp.lambda("guess", { answer, tries }); the endpoint checks the answer and saves the solve. A copy starts without server code and says answers can't be checked until its owner adds one (Brew Lambda). - Totals: The solver count moves live for everyone:
solves.onStats({}, paint).
Choices and totals: poll and RSVP
Poll. One question, a few choices, live totals for everyone. Try it live
For developers: how it saves
- Visitor calls: One vote per visitor under the fixed key
"me", so a second vote replaces the first. - State: Its
statedeclares the allowed values:{"collections":{"votes":{"mode":"private","choices":{"choice":["pizza","ramen","salad"]}}}}. - Totals: Votes stay private, yet
statscounts every vote for everyone:
templates/poll.html
async function show() {
try {
mine = await votes.get("me");
paint(live ? undefined : await votes.stats({ countBy: "choice" }));
} catch (e) {
oops(plain(e), row());
}
}
RSVP. A name, yes, maybe or can't come, and how many people come along. Try it live
For developers: how it saves
- Visitor calls: The reply is saved with
rsvps.set("me", v), so a guest can change it. - State: Its
state:{"collections":{"rsvps":{"mode":"private","choices":{"coming":["yes","maybe","no"]}}}}. - Totals: Totals for everyone:
templates/rsvp.html
function paintTotals(st) {
const by = (st && st.by) || {};
let sum = 0;
document.querySelectorAll(".totals li").forEach((li) => {
const c = li.dataset.c, n = by[c] || 0, b = li.querySelector("b");
sum += n; b.firstChild.data = n;
if (drawn) bump(b, n - (drawn[c] || 0));
});
drawn = by;
$("total").textContent = sum ? sum + (sum === 1 ? " reply" : " replies") + " in all." : "No replies yet.";
}
async function showTotals() {
try {
paintTotals(await rsvps.stats({ countBy: "coming" }));
For developers: totals right after a save
Totals from stats can lag a save by a few seconds, so a page should update what it shows right after its own save. onStats does that: it calls your function with the totals now, again right after each save on that list, then with the server's numbers, and keeps them live while the tab is visible.
const votes = s.col("votes");
if (votes.onStats) votes.onStats({ countBy: "choice" }, (st) => show(st.by));
else show((await votes.stats({ countBy: "choice" })).by);
Answers only you read: simple form, feedback, quiz, link page, advanced form and job application
Simple form. Name, email and a session to pick. Try it live
For developers: how it saves
- State: Its
state:{"collections":{"signups":{"mode":"private","choices":{"session":["morning","afternoon"]}}}}. - Visitor calls: Each visitor sees only their own reply and can edit or remove it, because it is saved under one key; on return the page fills the form again with
showMine(await signups.get("me")). Everyone sees how many signed up per session, never who:signups.onStats({ countBy: "session" }, paint).
templates/lead-form.html
$("signup").addEventListener("submit", async (e) => {
e.preventDefault();
if (!signups) return;
const v = { name: $("name").value.trim(), email: $("email").value.trim(), session: document.querySelector('input[name="session"]:checked').value };
if (!v.name || !v.email) return oops("Add your name and email first.", acts);
$("send").disabled = true; status.textContent = "Saving...";
try {
await hold(signups.set("me", v), mine && document.querySelector('[data-s="' + v.session + '"] .cnt'));
Feedback. Stars and an optional comment. Try it live
For developers: how it saves
- Visitor calls: The comment stays private; the average is counted from
feedback.stats({ countBy: "rating" }). Choice values are text, so the stars are saved as a string. - State: Its
state:{"collections":{"feedback":{"mode":"private","choices":{"rating":["1","2","3","4","5"]}}}}.
templates/feedback.html
const v = { rating: String(n), text: $("text").value.trim() };
$("send").disabled = true; status.textContent = "Saving...";
try {
await hold(feedback.set("me", v), mine && document.querySelector('#bars [data-r="' + n + '"] .n'));
Quiz. Five questions and a score; answers come back when the visitor returns. Try it live
For developers: how it saves
- State: Its
state:{"collections":{"answers":{"mode":"private"}}}. - Totals: Everyone sees how many took the quiz, never names or scores:
answers.onStats({}, paint). - Visitor calls: A saved value comes from the visitor's browser, so the quiz checks each field's type before it uses it:
templates/quiz.html
answers = s.col("answers");
if (answers.onStats) { answers.onStats({}, paint); live = true; } else await showCount();
try {
const saved = await answers.get("me");
if (saved && typeof saved === "object") {
$("name").value = typeof saved.name === "string" ? saved.name : "";
for (const [id] of QUESTIONS) form.elements[id].value = typeof saved[id] === "string" ? saved[id] : "";
Link page. Your links on your own domain, plus a newsletter sign-up with one email. Try it live
For developers: how it saves
- Where it saves: Saving works on a connected domain as well as on the BrewPage address.
- State: Its
state:{"collections":{"subscribers":{"mode":"private"}}}. - Totals: Everyone sees how many joined, never who:
subs.onStats({}, paint). - Owner view: Its owner block adds a Copy emails button.
templates/link-page.html
const email = $("email").value.trim();
if (!email) return oops("Add your email first.", $("send"));
$("send").disabled = true; status.textContent = "Saving...";
try {
await hold(subs.set("me", { email }), !!mine && mine.email !== email && $("subs"));
Advanced form. Two steps about a favourite local shop, a sample check before sending, then a screen of the visitor's own answers; nothing personal is asked. Try it live
For developers: how it saves
- State: Its
state:{"collections":{"answers":{"mode":"private","choices":{"type":["bakery","grocer","coffee","books","flowers","hardware"]}}}}. - Visitor calls: The answers are saved with
answers.set("me", entry), so a visitor can edit them; the kinds of shop are counted for everyone withanswers.onStats({ countBy: "type" }, ...), oranswers.stats({ countBy: "type" })where the script has noonStats. - Owner view: Its owner block reads every answer with
answers.list({ all: true, order: "-updatedAt", limit: 100, cursor }), a page at a time, draws charts of them and removes one withanswers.removeById(d.id).
templates/advanced-form.html
answers = s.col("answers");
if (s.onRole) s.onRole((r) => { const own = r === "owner"; $("owner-strip").hidden = $("owner-box").hidden = !own; if (own) showOwner(); });
if (answers.onStats) { answers.onStats({ countBy: "type" }, paintTotals); live = true; } else answers.stats({ countBy: "type" }).then(paintTotals, () => {});
try {
mine = await answers.get("me");
Job application. Two steps for an applicant: contact details, the role, a résumé as a PDF or a link, a short note and a start date. Try it live
For developers: how it saves
- State: Its
stateturns on files for the list:{"collections":{"applications":{"mode":"private","files":true}}}. - Visitor calls: The application is saved with
apps.set("me", entry), so an applicant can change what they sent, and the page shows it again after a reload. The résumé goes up first withapps.upload(file); the entry keeps the file ID, name, type and size. A failed receipt save can retry using the uploaded file. - Owner view: Its owner block reads every application with
apps.list({ all: true, limit: 50, order: "-updatedAt", cursor }), a page at a time, links each résumé and removes an application withapps.removeById(d.id), then its file withapps.removeFile(f.id).
templates/job-application.html
async function uploadResume(file) {
const uploaded = await apps.upload(file);
const meta = fileOf(uploaded);
if (!meta) throw new Error("The upload returned an invalid file reference.");
Games and saved progress
Clicker game. Dig for coins; the game comes back where the visitor left it. Try it live
For developers: how it saves
- State: Its
state:{"collections":{"saves":{"mode":"private"}}}. - Visitor calls: It keeps one entry,
saves.set("slot1", { ...game }), saves once after the tapping stops and again onvisibilitychange. Withnullthe game still plays, it just does not remember. - Totals: Everyone sees how many players have a saved game:
saves.onStats({}, paint).
templates/coin-cave.html
const saveSoon = () => { dirty = true; clearTimeout(timer); timer = setTimeout(save, 1500); };
Pocket Pairs. Flip two tiles at a time, match all six pairs and try to beat your best score. Try it live
For developers: how it saves
- State:
{"collections":{"saves":{"mode":"private","maxDocsPerVisitor":1}}} - One slot stores the deck, matched pairs, move count and best score for the returning player.
templates/pocket-pairs.html
await saves.set("slot1", { ...game, deck: game.deck.slice(), matched: game.matched.slice() });
Signal Grid. Each tap flips nearby lights. Share one page to solve the same puzzle together. Try it live
For developers: how it saves
- State:
{"collections":{"moves":{"mode":"private","maxDocsPerVisitor":10,"choices":{"marker":["tile-1","tile-2","tile-3","tile-4","tile-5","tile-6","tile-7","tile-8","tile-9","again"]}}}} - Each player owns a marker for each tile. A tile responds to the parity of its marker count and those of its neighbors. A tenth marker starts another round.
templates/signal-grid.html
async function totals(token) {
const stats = await moves.stats({ countBy: "marker" });
Expense rows and receipts
Expense Sheet. Import a CSV, edit expenses and check the total. A published copy also saves receipt attachments. Try it live
For developers: how it saves
- State:
{"collections":{"submissions":{"mode":"private","files":true,"maxDocsPerVisitor":1}}} - Each visitor saves one private sheet under
me. Rows contain the date, description, category, amount in cents and an optional receipt file. CSV import and export run in the browser.
templates/file-drop.html
async function readSheet() { return decode(await col.get("me")); }
Instead of an app: flashcards, habit tracker, to-do planner and movie club
What the AI changes (cards, habits, plan, films) sits in one JSON block in the page, each item with an id. To change it, edit only that block, keep the ids and update the same page: a new address starts with no saved progress. Without Page data (null), each one keeps progress in this browser's localStorage and says so.
Flashcards. Your AI writes the deck; each learner's progress is saved for their browser. Try it live
For developers: how it saves
- State:
{"collections":{"progress":{"mode":"private","maxDocsPerVisitor":1}}} - The cards come from the
deckblock ({id, front, back, note}). One entrymeper learner holds{c: {<card id>: [box 1-5, due day]}}, written at most every few seconds. The owner block shows counts per learner (cards studied, learned) with Remove.
templates/flashcard-deck.html
await (inflight = store.set("me", v));
Habit tracker. Check off daily habits on a week or month grid; streaks count days in a row. Try it live
For developers: how it saves
- State:
{"collections":{"checks":{"mode":"private","maxDocsPerVisitor":1}}} - The habits come from the
habitsblock ({id, name}). One entrymeper visitor holds{start: "YYYY-MM-DD", h: {<habit id>: hex}}: bit i of each hex map is daystart+ i. The owner block shows counts per visitor with Remove.
templates/habit-tracker.html
if (checks) await checks.set("me", entry(m)); else keep(m);
To-do planner. Tick the week's plan and add your own tasks; saved for this browser. Try it live
For developers: how it saves
- State:
{"collections":{"tasks":{"mode":"private","maxDocsPerVisitor":1}}} - The plan comes from the
planblock ({id, text, day}). One entrymeper visitor holds{v: 1, t: [[id, text, day or null, 0 or 1]], x: [ticked plan ids]}: own tasks plus the plan's ticks. The owner block shows counts only, never what visitors typed, with Remove.
templates/todo-planner.html
if (tasks) return tasks.set("me", v);
Movie club. A group film list: everyone marks what they have seen and rates it 1-10; the group average and who saw each film show live. Try it live
For developers: how it saves
- State:
{"collections":{"marks":{"mode":"shared","maxDocsPerVisitor":1,"choices":{"tick":["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31"]}}}}. The template page usesmovie-club.demo.json, the same list in private mode, so the demo shows only your own marks. - The films come from the
filmsblock. One entrymeper person holds{name, seen: {<film id>: 0-10}, tick}; each save sets a newtick, so the other open pages notice and readmarks.list({ order: "createdAt", limit: 100 })again. Names show as text. "Remove my name and marks" callsmarks.remove("me").
templates/movie-club.html
if (marks.onStats) { marks.onStats({ countBy: "tick" }, stats); live = true; } else await counts();
Test on your computer
Open the page as a file, or from a local server on localhost, 127.0.0.1, [::1] or a *.localhost name, and bp.state() returns a local preview instead of null. You add nothing to the page, and the same file publishes unchanged. Other addresses are not local, including 0.0.0.0, [::] and your computer's address on the network, which local servers often print: type localhost instead.
Serve the folder, then open http://localhost:8000/page.html (not the address it prints)
python3 -m http.server
- This browser only. Local entries stay in this browser. Nothing is sent to BrewPage, so the Data tab, the API and the MCP server never see them.
- How to tell.
s.localistrueand the console prints one “[BrewPage] Local preview” line that links back here. On a published pages.localis absent; show your own note withif (s.local)if you want one. - Owner view and the off state. Add
?bp-local=ownerto the address to see the owner view:s.roleis"owner",list({all: true})gives every entry the same fixedvisitorlabel, andremoveByIdworks.?bp-local=offturns the preview off, so you see what the page shows when saving is not available. Both do nothing on a published page. - One visitor. Every entry is yours (
mineis true). A private window starts empty. You cannot see a second visitor locally. - Your
stateis not read. Shared or private,"write": "author",choices,indexand per-list limits do not apply locally.stats({countBy})counts whatever is saved,order: "index"keeps creation order, and writes to an author-only list succeed. - Checked as when published: list and entry names, value rules, the default entry size, and one visitor's default entry and size limits, counted over all of the page's lists together; also the
listoptions. Local errors havee.status0. - Not checked locally: rate limits, the human check, refused content, cookies and network failures. Test those on the published link.
- Files upload into memory with a
blob:urland are gone after a reload. Every list takes them here; the types a list takes apply once published. bp.storageworks as before: kept in this browser.- Start over: run
localStorage.removeItem("__bp_state_local")in the console. All pages on one local host and port share these entries, as do files opened from disk in one browser; another port starts empty. If the browser gives the page no storage, entries are kept until you reload, and the console line says so. - Chat previews still get
null: save the file and open it, or use a local server. Keep theif (!s)guard, because chat previews, older copies of the script and other sites getnull.
Test, then publish
- 1Locally: save, reload, see the entry again. Try
?bp-local=ownerand?bp-local=off. - 2Publish with
statein a JSON body, and declare each list the way the page uses it: shared,choices,index,"write": "author". Local preview ignores these, so this is the step to read twice. - 3Open the returned
link. It is the page's own address, likeabc123.brewpage.app. Save once there. - 4Open the management link, then the Data tab: your entry is there. Delete your test entries before you share the link.
- 5Keep the line that tells visitors their entries are saved: see privacy.
The same steps in the editor and the Data tab, with the buttons to press: Help → First run.
Owner view on the page
A page can show you, its owner, more than visitors see: every entry, with a Remove button, right on the page. The owner is the browser where the page shows its owner gear; there s.role is "owner". The server decides who that is, so the page holds no secret and no password. It works on the page's own BrewPage address opened directly; on a connected domain or inside a frame everyone is a visitor. The exact rules: API → Owner view.
Every template has the same owner block. It starts hidden:
templates/guestbook.html
<section id="owner-box" aria-labelledby="owner-h" hidden>
<p class="only-you">Only you</p>
<h2 id="owner-h">All messages <small>Only you, the page's owner, see this.</small></h2>
<ul id="owner-list"></ul>
<button id="owner-more" type="button" hidden>Show more</button>
s.onRole shows it for the owner (the last line of start() above); if (s.onRole) guards older copies of the script. The block then reads every visitor's entries a page at a time:
templates/guestbook.html
async function showOwner(more) {
$("owner-more").hidden = true;
try {
const docs = await book.list({ all: true, limit: 50, cursor: more ? ownerNext : null });
if (!more) $("owner-list").replaceChildren();
for (const d of docs) $("owner-list").append(ownerRow(d));
ownerNext = docs.next; $("owner-more").hidden = !docs.next;
Each row's Remove button calls book.removeById(d.id), and each row shows d.visitor, a short label that tells visitors apart. To try it before publishing, open the file with ?bp-local=owner.
Files from visitors
A list can take files: photos for a gallery, a résumé with an application, a CSV. Add "files": true to the list in state, show the upload control when c.files is true, and keep each file in an entry so the page shows it again after a reload:
const photos = s.col("photos"); // state: {"collections":{"photos":{"files":true}}}
picker.hidden = !photos.files;
picker.onchange = async () => {
try {
const f = await photos.upload(picker.files[0]);
await photos.add({ fileId: f.id, url: f.url, name: f.name });
img.src = f.url;
} catch (e) { note.textContent = e.message; }
};
The browser sends JPEG and PNG photos as smaller WebP files. In a private list only the visitor who sent a file and you open it; in a shared list everyone on the page does. You see every file in the page's Data tab, with a preview of images and the start of text files, to download or delete. Deleting an entry keeps its file, so also call c.removeFile(f.id). Types and sizes: API → Visitor files. The job application template takes a résumé this way.
Prompts for your AI assistant
Copy a prompt into your assistant and fill in the last line. Share a management link only in a private session.
Build, test locally, then publish
Prompt: a new page that saves
Build one HTML file that saves visitor input with BrewPage Page data. Follow https://brewpage.app/llms-page-data.txt
Test saving and reading entries in local preview, then publish once with the matching state. Use a BrewPage tool that supports it, or authorized REST if none fits.
Give me the confirmed page link. Share any management link privately and save or privately hand off any owner token. If publishing is unavailable, give me the HTML and state JSON.
The page:
Make an existing page save
Prompt: add saving to a page you have
Make my page save visitor input. Follow https://brewpage.app/llms-page-data.txt
Update the same page with the list rules it needs. Keep its design, content and entries. Use an available BrewPage tool with my existing owner access, or authorized REST if none fits.
Give me the confirmed page link. Keep owner proof out of the page. If the update is unavailable, give me the change to apply.
My page link and HTML, if available:
Add an owner view
Prompt: show me every entry on the page
Add an owner view to my BrewPage page. Follow https://brewpage.app/llms-page-data.txt
Use s.onRole to show entries as text with a Remove button on the page's own BrewPage address when opened directly as owner. Test with ?bp-local=owner locally. Keep credentials out of the page.
Use a BrewPage tool with my existing owner access, or authorized REST if none fits. Update this page in place, keep saved entries and give me its confirmed link.
My page link:
Fix a page that does not save
Prompt: find out why nothing is saved
My BrewPage page does not save visitor input. Follow https://brewpage.app/llms-page-data.txt
Check its address, the published state, the SDK script, the if (!s) guard and the [BrewPage] console line. Use the SDK and treat saved entries as text.
Tell me the cause, then fix this page with my existing owner access using a BrewPage tool or authorized REST if none fits. Keep saved entries, keep owner proof private and give me the confirmed page link.
My page link:
A page that does not save
Open the browser console first: the script prints one [BrewPage] line that names the fix, and bp.state.reason gives the same reason as a word. Then find the symptom:
| Symptom | Cause | Fix |
|---|---|---|
Nothing saves on a brewpage.app/... address | Saving needs the page's own address | Give the page its own address: Help, step 1, or the hosting change |
| Nothing saves on the page's own address | Published without state, for example with a raw HTML body | Publish again with a JSON body and state, or press Turn on page data in the Data tab |
| Saves on its own tab, not inside another site | The page is shown in a frame (embedded) | Share the link instead of embedding the page |
bp is undefined, or the code never runs | A relative or changed script address, async on the tag, or a top-level await | Use the exact tag from the quick start and put your code in async function start() |
| Your page sets a Content-Security-Policy or has a service worker | They block the script or its requests | Let them through: API → Load the script |
| Worked locally, fails after publishing | Local preview ignores state: a field missing from choices, or a visitor write to an author-only list | Declare the list the way the page uses it, then publish again |
| Entries from another page show up locally | Pages on one local host and port, and files opened from disk, share one local store | Run localStorage.removeItem("__bp_state_local") in the console, or serve each page on its own port |
null in a chat preview | Chat previews are sandboxed | Open the file from disk or a local server, or test the published link |
| A save rejects | See e.code | Show e.message to the visitor; what to do per code: API → Errors |
| An entry shows as markup or breaks the page | The page renders entries with innerHTML | Use bp.text(value) or textContent |
Limits
Entries are small JSON values: text and numbers. Data is kept as long as the page and is deleted with it.
A visitor is one browser until they sign in to BrewPage; then their entries follow them to every device. A list with "write": "accounts" takes entries only from signed-in visitors, one per person; "accountOffer": false in state hides the sign-in offer. The calls: API → Signed-in visitors.
How big an entry can be, how many entries a visitor and a page hold, and what a free profile raises: API → Limits; for files: API → Visitor files. Every error code and what to do: API → Errors.
Tell your visitors
Show this line on every page that saves: “What you enter is saved on BrewPage and can be read by this page's author.”
On a shared list add: “Your message is public: everyone who opens this page can read it.”
Never ask visitors for passwords, card numbers or other credentials. You are responsible for what your page collects: Terms → Page data.
Page data FAQ
Do I need an account, a server or a key?
No. The page loads one script from BrewPage and holds no key. Publishing needs no account; a free profile keeps your pages in one place.
Can I test the page before I publish it?
Yes. Open the file from disk or from a local server and the script runs a local preview: entries stay in this browser and nothing is sent to BrewPage.
Who can read what visitors save?
You, the author, read every entry in the page's Data tab. Each visitor reads their own entries, and everyone reads a list you make shared.
Does it work on my own domain?
Yes. Saving works on the page's own BrewPage address and on a domain you connect to the page. A guest on both counts as two visitors; a visitor signed in to BrewPage is one.
Do visitors keep their progress on another device?
Yes, when they sign in. After a first save the page offers to keep their progress on all devices; sign-in opens in a new tab and the page stays as it is. Signed in to BrewPage, a visitor sees the same entries on every browser and device. You never learn who signed in.
How do I get the entries out?
Open the management link, then the Data tab, and download a CSV. An assistant can read them through the API or the MCP server with the management link.
Can I get a message when someone fills in my form?
Yes, with a free profile. The bell in the header shows new entries on your pages, and an email can tell you too: the first entry right away, then at most one summary an hour. Choose what you get in notifications.
Does it work for a multi-file site?
Yes. Publish the site with the state form field and load the script on each page that saves. Markdown pages never run scripts, so they cannot save.
How long are entries kept?
As long as the page. When the page is deleted, its entries go with it, so download them before then.