HTML pages

An HTML page is a custom app that lives in your space: a calculator, a simulation, an interactive chart, a dashboard, a game, a checklist or a slide show. It's an item in the tree like any page, and it opens at `openthink.app/n/<id>` (its code at `/n/<id>/code`).

What goes in it

One HTML file, with CSS in `<style>` and JavaScript in `<script>`. External libraries can be loaded from a CDN with `<script src>`. A fragment without an `<html>` tag is wrapped in a page frame for you. The page name comes from `<title>`.

Its look: design systems

A page can use one or more [design systems](https://openthink.app/n/8e23271237fe) — shared tokens, CSS and components. Choose them from the page's **⋯ → Design System…** menu, or add `<link rel="design-system" href="think://ds/<id>@<version>">` to the `<head>`. Then use the tokens and tags directly. With none chosen, the page uses the space's default design system.

Where it runs

HTML pages run in a sandboxed frame on their own origin: they can't call OpenThink's API and have no cookies. Instead, OpenThink gives every page a `think` object:

| You want to… | Use |

|---|---|

| Read and write rows in the space's data tables | `think.executeSql` |

| Run server-side code, such as calling an API with a secret key | `think.call` — see [Functions](https://openthink.app/n/0535ef448521) |

| Keep state in the URL (tab, year, input) so links reopen the same view | `think.params` |

| Keep live state an AI assistant can read and change | `think.state` |

| Know who is viewing | `think.viewer`, `think.requestViewer()` |

| Show a sign-in button | `think.signedIn`, `think.signIn()` |

| Hide editing tools from view-only visitors | `think.capabilities.canEdit` |

| Format numbers the way each viewer prefers | `think.format`, `think.parse` |

`localStorage` only lasts until the page reloads — use one of the above for anything that should persist. Full details: [HTML page API](https://openthink.app/n/880ac6e69d53).

Full screen

People who can't edit the page open it as a full-screen app. A ✕ button appears in the top-right corner for 2 seconds; tap an empty area (or hover the corner on a computer) to show it again, and Esc always exits. Games and drawing apps can take control of the exit button themselves.

Loading bar

While a page starts, OpenThink shows a thin bar at the top until the page has loaded and its first data queries have finished. Pages that are ready within 300 ms show no bar.

Embed in a text page

An HTML page can run inside a text page as a block. See [Embeds](https://openthink.app/n/6eb43cedc7d8).

Good to know

- Anyone who can open the page can read all of its code. Hiding something with `think.viewer` only changes what's drawn — keep secret data in a [sealed table](https://openthink.app/n/26c72c31ab9c), and API keys in a [function's secrets](https://openthink.app/n/0535ef448521).

- View-only visitors can read the tables whose names appear in the code (except sealed tables), but can't write to them unless you give them [row-level permissions](https://openthink.app/n/26c72c31ab9c).