Recipes

Each recipe is code that runs in CI: the source shown is the source tested in apps/recipes. Generated by pnpm docs:gen; do not edit by hand.

  • A chat for analytics users: AnalyticsChat is a chat for people who work with data. The conversation is always there; everything else appears only when you pass its prop:
  • Ask a person before a query runs: An agent that wants to run SQL shows it to a person first. The person can allow it, deny it, or edit it and allow their version. Only what they allowed runs, and only after the agent has checked the answer.
  • A dashboard a person can arrange: Any page drawn from a PageDocument can offer Arrange: a person drags a component by its bar to before or after another, to the side zone of one to put the two side by side (where they would be drawn side by side), or into a container; a line, the container that takes it and the half a new column would take are drawn while it moves, and a page that lays out across has bands above and below everything; drags the handle under it to change its height, or at its right edge to change widths. Every drag has a keyboard form (the bar's arrows, arrow keys on the handles), and drags use pointer events, so they work by touch and pen.
  • Chat with Claude over your own data: Run Claude on your server as the chat's agent. It sees your tables through a list_tables tool, draws charts, tables and numbers from the catalog, and those components run their SQL through your read-only data source. The browser talks only to your server, so the API key never reaches it.
  • Connect Postgres, Teradata and S3: One surfaces.config.ts that reads a Postgres database, a Delta table in S3 and a Teradata system, all read-only, with every credential named by a secret and read from the server's environment. A source that cannot be reached does not stop the server; testSource says what is wrong.
  • A dashboard from SQL with cross-filtering: One query feeds headline numbers, two bar charts and a table. Clicking a bar filters every other view, each filter can be removed with a button, and every view asks the engine for its own summary, so nothing is filtered or grouped in the browser.
  • A form that writes back: A page with a Form whose submissions the dev server checks and stores, then serves back as a read-only table. The server owns the form: its fields, their rules and where submissions go. The browser sends a form id and values, never SQL, a table or a path.
  • Records a person manages: A page of accounts an admin manages: searched, filtered, sorted and paged on your server, changed one at a time from a row or many at once, including everyone a search matches on pages never opened. The same shape fits invitations, jobs, keys or anything else your own server holds. It is built from DataTable, SelectionBar, Pagination, useConfirm, StatusBadge, SegmentedControl and ActionReceipt, with no table, dialog or bar of its own.
  • Show live views in Claude Desktop (MCP Apps): Give an MCP host such as Claude Desktop tools that show live tables, charts, pivots, an SQL editor and agent-drawn surfaces over your data. The model calls a tool; the host shows the Surfaces app page, which fetches only the rows on screen. Queries stay on your machine and run read-only.
  • Embed in a Next.js app: Put a query result into a page of an existing Next.js app, themed only in its own region, talking to your data server from the browser. The component is ordinary React with "use client" at the top; the page loads it in the browser only.
  • Serve a site's pages from Next.js: Serve pages written in the site catalog (by an agent or by hand) as the routes of a Next.js app, or as parts of pages you write yourself, with static export. @surfaces-ui/next works out the routes and metadata and draws each page. Next.js does the routing, building and hosting. Every page is rendered to HTML on the server, so its words, headings, links and theme are in the file before any script runs.
  • Bring your own backend (DataSource): Every component reads data through one interface, DataSource. If you already have a query API, write an adapter for it and install no data-layer package: no engine, no dev server, no Connect client. This recipe adapts a plain HTTP API that answers with Arrow, and adds a small wrapper that limits which sources a page can reach.