Apps and pages
Apps and pages
An app is a folder under src/app/ with a +app.ts and one Svelte file per page. Most pages are a few lines: shared views read the model and give people tables, boards, forms, filters, import and export.
// src/app/field_ops_controller/+app.ts (field-operations)
import { app } from '@norbital-ai/bolt';
export default app({
title: 'app.field_ops_controller.title',
description: 'app.field_ops_controller.header_description',
icon: 'lucide:building-2',
pages: {
dispatch: { title: 'app.field_ops_controller.tab_dispatch', icon: 'lucide:kanban' },
sites: { title: 'app.field_ops_controller.tab_sites', icon: 'lucide:map-pinned' }
}
}); The keys of pages match the page files (+dispatch.page.svelte, +sites.page.svelte) and set the navigation order. A policy's capabilities.apps decides who sees the app. A +group.ts folder gathers several apps under one entry.
A page
<!-- src/app/field_ops_controller/+sites.page.svelte (field-operations, shortened) -->
<script lang="ts">
import type { PageContext } from '@norbital-ai/bolt/page';
import { Table } from '@norbital-ai/ui';
import { AppShell } from '@norbital-ai/ui/layout';
let { ctx }: { ctx: PageContext } = $props();
const t = ctx.t;
</script>
<AppShell
icon="lucide:map-pinned"
title={t('app.field_ops_controller.tab_sites')}
description={t('app.field_ops_controller.sites_description')}
>
<Table
{ctx}
of="sites"
order_by={{ name: 'asc' }}
columns={['name', 'unit_number', 'address']}
toolbar={{
title: t('app.field_ops_controller.tab_sites'),
new: true,
actions: [
{
icon: 'lucide:key-round',
name: t('app.field_ops_controller.site_handover'),
run: (ids) => ctx.run('site_handover', { ids }),
requires_selection: true
}
]
}}
/>
</AppShell> Every page receives ctx as a prop. Pass it to the shared views: they read through it under the viewer's policies and update live.
What happens when it runs
- A controller opens the Sites page.
Tablereadssitesthrough their policies and stays live. - They select two sites and click Site handover. The page calls
ctx.run('site_handover', { ids }). - The automation runs with its own policies, and the table shows the change as soon as it is saved.
Shared views
Table, Board (cards in lanes) and Chart come from @norbital-ai/ui. Each takes of (the model), where, order_by, columns and a toolbar with a title, New, selection and actions. Opening a row shows the record with its fields, related lists, history and any approval. Write your own page only for a task these views cannot express.
On a Board, dragging a card to another lane updates the field the lanes come from, through the same checks as any edit; a refused move explains why. A Map places records by a point field, and clicking a marker opens the record.
Record views and custom fields
A model's optional +representation.svelte replaces its default record layout. A custom field type in src/data/custom_field/<name>/ has a +custom_field.ts that checks its value and an optional +renderer.svelte. The renderer then appears in every table cell, form, card and history entry that shows the field.
Your own reads and writes
For anything bespoke, read with ctx.query and write with ctx.act or ctx.run, as in Reading and writing data. Compose surfaces with <Surface> and custom interactive controls with @norbital-ai/ui/behaviors — the same headless Svelte-5 behaviors that power the built-in kit. Keep only plain values in $state, and use ctx.t for every label.
Public apps and kiosks
An app's audience decides who opens it: members (the default), external members such as customers, all, or { public: [policies] } for visitors without an account. A public page is rendered on the server, and each visitor gets an anonymous identity that owns what they create. An app with shell: 'kiosk' is a full-screen app for a shared device, served at /kiosk/<app>/<page> under the policies it names.
An app that needs the device declares requires, such as location or camera. Its pages use ctx.device for location, notifications and opening links.