Build your first app
In 10 minutes you'll build a lunch vote for your team: everyone taps a dish, and every phone updates the moment someone votes. Along the way you'll use the three things every OpenThink app is made of — a **database**, **live updates** and **accounts**.
This is the app you'll build. It's running right here on this page:

1. Create the database
In your space, create a data table named **Lunch votes** with these columns:
| Column | Type |
|---|---|
| Name | Name (title) — the dish |
| Date | Date |
| Voter | Text |
| Voter ID | Text |
Each vote is one row. There's no server to set up — the table *is* the database. → [Connect your database](https://openthink.app/n/03134f0f5a9f)
2. Create the app
Create an HTML page in the **same space** and paste:
```html
<title>Lunch vote</title>
<h1>What's for lunch?</h1>
<div id="who"></div>
<div id="dishes"></div>
<script>
const DISHES = ["Phở", "Cơm tấm", "Bún chả", "Pizza"];
const today = new Date().toLocaleDateString("en-CA"); // yyyy-mm-dd
async function draw() {
// Who is voting?
const v = think.viewer;
who.innerHTML = "";
if (v) who.textContent = "Voting as " + v.name;
else {
const b = document.createElement("button");
b.textContent = think.signedIn ? "Vote with my name" : "Sign in to vote";
b.onclick = () => think.signedIn ? think.requestViewer().then(draw) : think.signIn();
who.append(b);
}
// Today's votes
const { rows } = await think.executeSql(
'SELECT _id, "Name", "Voter", "Voter ID" FROM "Lunch votes" WHERE "Date" = ?', [today]
);
const mine = v && rows.find(r => r["Voter ID"] === v.id);
dishes.innerHTML = "";
for (const dish of DISHES) {
const votes = rows.filter(r => r["Name"] === dish);
const b = document.createElement("button");
b.textContent = `${dish} — ${votes.length} ${votes.map(r => r["Voter"]).join(", ")}`;
b.disabled = !v;
b.onclick = async () => {
if (mine) await think.executeSql('UPDATE "Lunch votes" SET "Name" = ? WHERE _id = ?', [dish, mine._id]);
else await think.executeSql(
'INSERT INTO "Lunch votes" ("Name", "Date", "Voter", "Voter ID") VALUES (?, ?, ?, ?)',
[dish, today, v.name, v.id]
);
draw();
};
dishes.append(b);
}
think.ready();
}
addEventListener("think:data", draw); // someone voted somewhere else
addEventListener("think:viewer", draw); // the viewer shared their name
draw();
</script>
```
Tap a dish — a row appears in **Lunch votes**. Tap another dish — your row changes instead of adding a second vote.
3. Make it live
Open the app in a second tab, or on your phone, and vote there. The first tab updates by itself. That's the one line `addEventListener("think:data", draw)`: whenever the table changes — another tab, another person, an AI assistant — the app redraws. No refresh, no polling. → [Live collaboration](https://openthink.app/n/5b39c176b328)
4. Let your team vote
The app already knows who's voting: `think.viewer` gives each person's name and a permanent account id, and the app stores that id with the vote. Now decide who may vote:
- **Your team.** Invite them to the app by email, and give them a row-level permission on **Lunch votes** — **Read all, edit own** lets everyone see all votes but change only their own.
- **Anyone with the link.** Share the app with "Anyone with the link can view", give link visitors the same row-level rule on the table, and turn on **Ask viewers for their name and picture** so the app gets their name.
Voting requires sign-in, and with a row-level rule every row also records who created it. → [Authentication, authorization & accounting](https://openthink.app/n/b78dd1e6ad82)
5. Ship it
- Open the app on a phone: people who can't edit it get it full screen, like an installed app.
- Put it next to your notes by embedding it in a text page — exactly like the one at the top of this page. See [Embeds](https://openthink.app/n/6eb43cedc7d8).
- Publish a version to freeze what people see while you keep improving the draft. See [Versions & publishing](https://openthink.app/n/615848fbc70f).
Faster: ask your AI assistant
Connected through [OpenThink MCP](https://openthink.app/n/386121a81507), Claude can do steps 1 and 2 for you:
> Create a "Lunch votes" table and an HTML page in this space where each person votes for one dish a day, sees everyone's votes live, and can change only their own vote.
What's next
- [Design guidelines](https://openthink.app/n/468f02cd6da1) — make it calm, phone-first and right for every visitor
- [Connect your database](https://openthink.app/n/03134f0f5a9f) — reading, writing and SQL values in depth
- [Live collaboration](https://openthink.app/n/5b39c176b328) — `think:data`, shared state with your AI assistant, state in the URL
- [Authentication, authorization & accounting](https://openthink.app/n/b78dd1e6ad82) — sign-in, roles, row-level rules, sealed tables
- Full reference: [HTML page API](https://openthink.app/n/880ac6e69d53)