# Pages and navigation

> Reference for definePage in a plugin, registering a page, adding it to the navigation or to Settings, and shipping browser components.

A plugin page is a screen that your plugin adds to the workspace. You define what it shows, then register it and, if you want, add a link to it. A page returns the same builtin [components](/docs/build/components) that adapters use.

## Define and register a page

`definePage` takes a `path` and a `render` function. In `setup`, register the page with an `id` and a `title`, then add a navigation entry:

```ts
import { definePage, PageHeader } from "@northgraindata/dsui-plugin-sdk";

const overview = definePage({
  path: "/",
  render: () => [PageHeader({ title: "My plugin" })],
});

// Inside setup(registry):
registry.page(overview, { id: "overview", title: "My plugin" });
registry.navigation({
  id: "overview-link",
  area: "primary",
  label: "My plugin",
  pageId: "overview",
});
```

### Page options

| Option | Meaning |
| --- | --- |
| `id` | Unique within the plugin. Navigation entries refer to it as `pageId` |
| `title` | The title that people see |
| `description` | A sentence that describes the page |
| `settings` | Adds the page to Settings. See below |
| `shell` | `app` (default) frames the page in the workspace, and `bare` renders only its content, which suits a sign-in screen |
| `public` | Serves the page without a signed-in person. Only a plugin with `security: true` may set it |

### Navigation entries

A navigation entry has an `id`, a `label`, the `pageId` of a page in the same plugin, an `area` of `primary` or `secondary`, and an optional `order` that sorts entries within the area.

## Path patterns

A path can contain static segments, `:name` params, and one `*name` wildcard as the last segment. For `/services/:serviceId/items/*path`, DSUI captures `serviceId` and the rest of the path as `path`. The wildcard can be empty. Params are decoded, so percent-encode a path segment when you build a link.

```ts
definePage({
  path: "/files/*path",
  render: ({ params }) => [PageHeader({ title: `path=${params.path}` })],
});
```

Adapter pages don't support wildcards. A plugin page does.

## Read the plugin context

`render` receives `params` and a `context`. Give the page a context type so you can read the plugin's settings and the host's capabilities:

```ts
definePage<"/services", PluginContext<MyConfig>>({
  path: "/services",
  render: async ({ context }) => {
    const { items } = await context.services.list({ limit: 24 });
    return [/* … */];
  },
});
```

See [host capabilities](/docs/plugin-sdk/host-capabilities) for what the context offers.

## Add a page to Settings

Add `settings` to a page to list it in the Settings navigation. DSUI groups entries by category.

```ts
registry.page(configurationPage, {
  id: "configuration",
  title: "My plugin settings",
  settings: {
    label: "My plugin",
    category: "Integrations",
    order: 10,
    permission: "manage",
  },
});
```

- The page must use a static path without required params
- The default permission is `manage`. DSUI enforces it on the navigation entry and on direct requests for the page
- A plugin that is disabled, unavailable, or removed adds no Settings entry
- The plugin keeps its own validation and storage for its settings

## Ship browser components

Builtin components render through the host. For a custom component, declare a browser entry with `dsui.browser` in your `package.json`, or set `browserBundle` for an installed plugin. See [custom components](/docs/build/custom-components) for how to write one.
