> ## Documentation Index
> Fetch the complete documentation index at: https://trytilde.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Add a space in spaces/

> Add a React space to a Tilde project: a page fed only by the ontology's reads and actions, which people open in Live.

A space is a React app on your ontology. It gets data only from the ontology's reads, actions, and realtime views, through a typed client Tilde generates, so the same policies govern it. People open spaces in **Live**, and you can [embed](https://trytilde.ai/docs/embed/spaces.md) them in your own product. See [Spaces](https://trytilde.ai/docs/ontology/spaces.md) for more.

## The package

`spaces/` is one npm project. Each folder in it is one space, and the folder name is the space's id.

```json spaces/package.json theme={"system"}
{
  "name": "helpdesk-spaces",
  "private": true,
  "type": "module",
  "dependencies": {
    "@bufbuild/protobuf": "^2.10.0",
    "@connectrpc/connect": "^2.1.0",
    "@connectrpc/connect-web": "^2.1.0",
    "@tailwindcss/cli": "^4.1.0",
    "react": "^19.1.0",
    "react-dom": "^19.1.0",
    "tailwindcss": "^4.1.0"
  }
}
```

Tilde provides `@tilde/spaces` (hooks and components) and `@tilde/contract` (your handlers, typed) at build time, so don't list them.

## A page

A space default-exports a component, and exports a `title`. This one lists customers, shows one, and logs a call with the `setNotes` action.

```tsx spaces/customers/index.tsx theme={"system"}
import { useState } from "react";
import { customerOverview, listCustomers, setNotes } from "@tilde/contract";
import { Card, Page, useAction, useRead } from "@tilde/spaces";

export const title = "Customers";

export default function Customers() {
  const customers = useRead(listCustomers, { input: {} });
  const [key, setKey] = useState("acme");
  const overview = useRead(customerOverview, { key, input: {} });
  const save = useAction(setNotes);

  return (
    <Page title={title}>
      <select value={key} onChange={(e) => setKey(e.target.value)}>
        {customers.data?.map((c) => <option key={c.customerId} value={c.customerId}>{c.name}</option>)}
      </select>
      <Card title={overview.data?.name}>
        <p>Plan: {overview.data?.plan}</p>
        <p>Notes: {overview.data?.notes ?? "none"}</p>
        <button onClick={() => save.run({ key, input: { notes: "Called today" } }).then(() => overview.refetch())}>
          Log a call
        </button>
      </Card>
    </Page>
  );
}
```

* Importing a handler that doesn't exist is a build error.
* When a page needs new data, add a read to the ontology in the same change.
* Opening the space needs an `openSpace` policy. The `open-customers` policy in [The ontology](https://trytilde.ai/docs/project/ontology.md#policies) grants it.

## Next

[Add an agent](https://trytilde.ai/docs/project/agents.md) that uses the same reads and actions.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.