Build a custom page
Goal
Ship a React page inside a custom app (renderer: 'custom') instead of the generic list/detail renderer. See Apps and renderers for the model.
When to go custom
Stay on renderer: 'generic' when the app is CRUD over typed records — the generic renderer gives you list/detail/create/sort/permission-aware editing for free from views.default_list / views.default_detail. Go custom for dashboards, wizards, bespoke layouts, or anything not expressible as schema-driven list/detail — GenericAppShell only generates routes for nav items carrying type_slug (.framework/src/components/app-shell/GenericAppShell.tsx).
Steps
Scaffold the app (or reuse one):
npx spine-framework create-app <slug> --role <role-slug>Writes
custom/apps/<slug>/withmanifest.json,package.json,index.tsx,components/, andpages/(validates clean againstvalidate-app), and inserts theappsrow withrenderer: 'custom'(.framework/cli/commands/create-app.ts). Pass--rolea slug that exists inroles— the defaultmemberis seeded by073_seed_member_roles.sql.Add pages under
custom/apps/<slug>/pages/.CustomAppLoaderlazy-imports onlycustom/apps/<slug>/index.tsx(import.meta.glob('../../../custom/apps/*/index.tsx'),.framework/src/components/CustomAppLoader.tsx) —index.tsxdefault-exports the component (usually its own<Routes>) and imports the page components itself.// custom/apps/<slug>/pages/DashboardPage.tsx export default function DashboardPage() { /* ... */ }- Set the app row.
renderer: 'custom',route_prefix: '/<slug>',min_role/required_roles,nav_itemsfor the sidebar.AppWrapperenforces auth + role before mounting your app (.framework/src/components/AppWrapper.tsx). Fetch data through
/api/admin-data— never write a bespoke CRUD function:import { apiFetch } from '@core/lib/api' const res = await apiFetch( '/api/admin-data?action=list&entity=items&type_slug=ticket&limit=50') const { data } = await res.json()apiFetchattaches the Supabase Bearer token and theX-Account-Idheader (.framework/src/lib/api.ts). Find-or-create related records (e.g. a thread for a work item) through the same endpoint — see Build your first app — Step 4 for the full call shapes.- Rebuild and run.
npm run assemble(ornpm run dev/dev:netlify, which run assembly automatically). Custom functions go incustom/functions/prefixedcustom_— assembly hard-fails on a basename collision with a framework function (scripts/assemble-functions.sh).
Verify
- Navigate to
/<slug>—CustomAppLoaderresolves yourindex.tsx(a missing entry shows theApp "<slug>" not founderror naming the expected path). GET /api/apps?action=get&slug=<slug>showsrenderer: 'custom'and the rightroute_prefix.npm run typecheckcompiles the page.
Common mistakes
- A bespoke CRUD endpoint. Custom Netlify functions that create/update/list runtime records bypass
admin-data's permission, type-resolution, audit, and trigger logic — call/api/admin-datafrom the client instead (see Write a function for the cases where a custom function is allowed). - Forgetting
index.tsxis the only entry. New pages inpages/are invisible untilindex.tsxroutes to them. type_slugnav items on a custom app — they only do something under the generic renderer; use plainpathnav items and route them yourself.- Editing before re-assembling —
CustomAppLoader's glob is evaluated at build time; new files need an assemble/dev restart.