Connect with AI

OpenThink apps are built to work with an AI assistant such as Claude, connected through [OpenThink MCP](https://openthink.app/n/386121a81507). The assistant can work with your app in three ways:

| | The assistant… | You use |

|---|---|---|

| **Build** | writes the app and sets up its tables | OpenThink MCP |

| **Drive** | reads and changes the app's data, and the app updates on screen | Data tables + `think:data` |

| **Play along** | sees what's on your screen right now and changes it | `think.state` |

Build: describe the app, get the app

Ask in plain words. The assistant creates the data tables, writes the HTML page, and can take a screenshot of the page exactly as you see it to check its own work.

> Create a "Reading log" table (book, author, pages, finished date) and an HTML page in this space that shows how many pages I read each month, with a form to add a book.

Better prompts get better apps:

- **Name the space, the tables and the columns.** The app can only use tables in its own space, and SQL refers to them by name.

- **Say who will open it.** "Only me", "my team, each editing their own rows" or "anyone with the link, view only" — the assistant then sets up the right [permissions](https://openthink.app/n/b78dd1e6ad82).

- **Point to the guidelines.** "Follow the OpenThink Design guidelines" — phone first, calm colors, line icons. See [Design guidelines](https://openthink.app/n/468f02cd6da1).

- **Iterate.** "Make the numbers bigger", "add a By category tab". Every edit goes into version history, so you can always go back. See [Versions & publishing](https://openthink.app/n/615848fbc70f).

Drive: talk to the app's data

Because an app keeps its data in tables, the assistant can work with that data while the app is open — and the app redraws the moment the table changes, through the `think:data` event.

> Tick Towel and Goggles on my packing checklist.

> Add today's lunch, 65,000đ, to Expenses.

> Which category did I spend the most on last month?

Nothing special is needed in the app beyond listening for changes:

```js

addEventListener("think:data", draw); // a table changed — maybe by your assistant

```

See [Live collaboration](https://openthink.app/n/5b39c176b328) and the [Packing checklist](https://openthink.app/n/0a0ed8fc5305) in action.

Play along: share the screen's state

Some things aren't records worth keeping in a table — a chess position, the step someone is on, the card they're looking at. `think.state` is a small JSON object that you and your assistant both read and write live, per page and per person.

```js

draw(think.state);

// You make a move: tell the assistant

board.onmove = (fen, move) => think.setState({ fen, lastMove: move });

// The assistant makes a move: show it

addEventListener("think:state", (e) => {

draw(e.detail.state); // e.detail.by is "mcp" (assistant) or "web" (you)

});

```

Now you can say *"your move"* and the board on your screen changes, or ask *"why was that a bad move?"* and the assistant reads the exact position.

Tips:

- **Describe the state in the code.** A short comment listing each key and what it means (`// fen: board position, lastMove: "e2e4"`) helps the assistant read and write it correctly.

- **Keep it small** — up to 16,000 characters. Long-term data belongs in tables.

- **Only call `setState` from the viewer's actions.** On load, the saved state can arrive a moment later in a `think:state` event; writing defaults at startup would overwrite it.

- State isn't saved for signed-out viewers, fixed versions, the code view or the iPhone app.

Good to know

- The assistant acts as you: it sees and changes only what your account can.

- It should ask you before opening a public link, moving things to the trash, deleting rows, or publishing and restoring versions.

- Full reference: [HTML page API](https://openthink.app/n/880ac6e69d53) · Setting up the assistant: [OpenThink MCP](https://openthink.app/n/386121a81507)