Core · Developing apps · Client

Pages, routes and navigation

Use defineAppRoutes() to declare page addresses, components, navigation and access rules. To run the example app and prepare an account, see environment and startup.

Register pages

Declare routes and connect them to the runtime

Declare pages in client/pages/projects/routes.ts and collect them for the runtime in client/routes.ts. This excerpt keeps the project list declaration and omits its outer group and child routes:

TypeScript
// client/pages/projects/routes.ts (excerpt: outer group and child routes omitted)
import { FolderKanban } from 'lucide-react';
import { defineAppRoutes } from '@nocobase/app-client/plugins';

export const projectRoutes = defineAppRoutes([
  {
    name: 'projects',
    path: '/projects',
    auth: 'required',
    authz: { resource: { type: 'page', id: 'projects' }, action: 'access' },
    navigation: { title: 'demo.projects', icon: FolderKanban },
    componentLoader: () => import('./index.js'),
  },
]);
TypeScript
// client/routes.ts
import { projectRoutes, appendedRoutes } from './pages/projects/routes.js';
// Retain the template appRoutes and systemSettingsRoutes.
export default [appRoutes, appendedRoutes, projectRoutes, systemSettingsRoutes];

defineAppRoutes() takes a readonly array of definitions and returns a frozen { parent: 'app', routes: [...] } contribution. It does not load components immediately. Runtime routes accepts one contribution or a flat array of contributions; the template already imports this file in client/runtime.ts. Calling the function in an unused file does not register anything. Do not mutate the returned object or pass an array of contributions back into defineAppRoutes().

Open Project list from the example home page to see the registered page and its navigation entry. Its authz requires project access, which the example administrator has.

A static project page with a default component export and navigation entry
A static project page with a default component export and navigation entry

View source

Load page components

componentLoader must return Promise<{ default: Component }>. The project list uses import('./index.js') to load the default export from index.tsx. The page uses the template's reusable PageContainer, PageHeader and DataTable components.

A module can also provide a named export. The standalone project route uses ProjectPage from workspace.tsx, adapting it to the required structure:

TypeScript
// client/pages/projects/routes.ts
componentLoader: () =>
  import('./workspace.js').then((module) => ({ default: module.ProjectPage })),

Select Open as a full page in the project drawer to see this named export at /project-pages/p100.

A loader receives no route parameters and is not a data fetching function. Read parameters inside the component, and see data requests and state management for fetching data. Do not return a JSX element directly from the loader.

The standalone project page loaded through a named export
The standalone project page loaded through a named export

View source

Path parameters and page navigation

Static paths and dynamic parameters

A route's path is relative to the application. With the default /main deployment prefix, /projects appears as /main/projects in the browser. Keep /main out of route declarations.

The example routes use both static paths and dynamic parameters:

Application pathPurpose
/projectsProject list
/projects/newDraft form; static new takes precedence over :projectId
/projects/:projectIdOpen details by project ID
/projects/:projectId/tasks/:taskIdIdentify both a project and a task

detail.tsx uses React Router's useParams() to read a parameter and find its demonstration record:

TSX
import { useParams } from 'react-router';
import { projects } from './data.js';

// Inside the ProjectDetail component
const { projectId } = useParams();
const project = projects.find((item) => item.id === projectId);

Parameter values are strings, and children can read parent parameters. /projects/p100 resolves Harbor launch; /projects/missing displays a missing-record message. The template handles route matching; the page implements record lookup and missing-record handling.

An unknown project displays a missing-record message
An unknown project displays a missing-record message

View source

Query parameters and navigation

Enter Harbor in Search projects. The address becomes /projects?q=Harbor; selecting Harbor launch opens /projects/p100?q=Harbor. index.tsx updates the query through React Router's useSearchParams(). This excerpt omits table configuration and unrelated component props:

TSX
// client/pages/projects/index.tsx
const location = useLocation();
const [search, setSearch] = useSearchParams();
const query = search.get('q') ?? '';

<Input
  value={query}
  onChange={(event) => {
    const next = new URLSearchParams(search);
    if (event.target.value) next.set('q', event.target.value);
    else next.delete('q');
    setSearch(next, { replace: true });
  }}
/>

// Inside the DataTable name cell
<RecordLink to={{ pathname: row.original.id, search: location.search }}>
  {row.original.name}
</RecordLink>

RecordLink wraps React Router's Link. Relative p100 extends the list path. Pass the query explicitly: nesting does not preserve it automatically. The list filters its fixtures by q; setSearch(next, { replace: true }) avoids creating a history entry for each edit.

The q query filters the list and is included in detail links
The q query filters the list and is included in detail links

View source

Nested routes and page presentation

Standalone pages and child routes

A page can be registered independently or as another page's child. The difference is whether it renders through the parent's content outlet:

DeclarationExample addressContent location
Sibling of the list/project-pages/p100Standalone page, outside the list outlet
Inside the list's children/projects/p100The list's Outlet

The standalone page in routes.ts is a sibling of the list and reuses ProjectPage:

TypeScript
// A sibling route of projects
{
  name: 'projectStandalone',
  path: '/project-pages/:projectId',
  authz: { resource: { type: 'page', id: 'projects' }, action: 'access' },
  breadcrumb: { title: 'demo.projectPage' },
  componentLoader: () =>
    import('./workspace.js').then((module) => ({ default: module.ProjectPage })),
}

See the screenshot under Load page components: the standalone page reuses the named export without the list outlet.

Select Open as a full page in the drawer to open this independent page. To host details within the list instead, declare the hierarchy through children:

TypeScript
// Children of the projects page (excerpt)
children: [
  {
    name: 'projectDetail',
    path: ':projectId',
    componentLoader: () => import('./detail.js'),
    children: [
      {
        name: 'projectTask',
        path: 'tasks/:taskId',
        componentLoader: () => import('./task.js'),
      },
    ],
  },
],

The parent must render React Router's Outlet. This list also passes its query through context; the detail component reads it with useOutletContext():

TSX
// client/pages/projects/index.tsx
const context = useMemo(() => ({ listSearch: location.search }), [location.search]);

<Outlet context={context} />

children defines the hierarchy, and Outlet supplies a rendering location. The page component chooses whether to embed content, cover the parent, or display a drawer or dialog. A child route declaration does not create those presentations automatically.

View source

Embedded child pages and default tabs

Open Project reports. /reports redirects to /reports/summary; Owners switches to /reports/owners. reports/index.tsx redirects only when the address exactly matches the parent:

TSX
// client/pages/reports/index.tsx (excerpt)
const location = useLocation();
const parent = useResolvedPath('.');
if (matchPath({ path: parent.pathname, end: true }, location.pathname)) {
  return <Navigate replace to={{ pathname: 'summary', search: location.search }} />;
}

// These elements go in the navigation and content returned by the component.
<NavLink to={{ pathname: 'owners', search: location.search }}>
  {t('demo.owners')}
</NavLink>
<Outlet />

Navigate replace avoids adding a redundant parent entry to history. end: true prevents a direct visit to Owners from being redirected to Summary. NavLink identifies the active tab; Outlet renders its content. Both children inherit the report page's authorization.

The parent report address opens Summary by default
The parent report address opens Summary by default
Opening Owners directly preserves that tab and its parent navigation
Opening Owners directly preserves that tab and its parent navigation

View source

Child pages that cover parent content

Select Open workspace in the drawer to open /projects/workspace/p100?q=Harbor. workspace.tsx uses the template's RouteChildPage to cover the parent content while keeping the application navigation available:

TSX
// Another child of the projects page
{
  name: 'projectWorkspace',
  path: 'workspace/:projectId',
  breadcrumb: { title: 'demo.workspace' },
  componentLoader: () => import('./workspace.js'),
}

// client/pages/projects/workspace.tsx
export default function ProjectWorkspace() {
  return <RouteChildPage><ProjectPage /></RouteChildPage>;
}

The workspace still renders through the list's outlet. Its heading and breadcrumb use the project name; see static and dynamic breadcrumbs for that configuration.

RouteChildPage covers the list content while keeping application navigation
RouteChildPage covers the list content while keeping application navigation

View source

Route drawers and nested dialogs

detail.tsx uses the template's RouteDrawer to display the project. This excerpt omits record lookup, missing-record handling and other buttons:

TSX
// client/pages/projects/detail.tsx (excerpt)
const { projectId } = useParams();
const { listSearch } = useOutletContext<{ listSearch: string }>();

<RouteDrawer title={project.name} footer={<CloseButton />}>
  <RecordLink to={{ pathname: `tasks/${task.id}`, search: listSearch }}>
    {task.name}
  </RecordLink>
  <Outlet />
</RouteDrawer>

Selecting a project opens the drawer over the filtered list. Opening or refreshing /projects/p100?q=Harbor restores this page state.

The detail drawer keeps the filtered list behind it
The detail drawer keeps the filtered list behind it

Select Prepare launch checklist to open /projects/p100/tasks/t200?q=Harbor. task.tsx reads its own parameter and the parent parameter, then renders RouteDialog:

TSX
// client/pages/projects/task.tsx (excerpt)
const { projectId, taskId } = useParams();

<RouteDialog title={task.name} footer={<CloseTask />}>
  <p>{t('demo.taskPath', { projectId, taskId })}</p>
</RouteDialog>

Keep the second Outlet inside the detail drawer: it renders the task dialog. Back to project closes only the inner dialog. Closing the drawer then returns to the list.

A task dialog above the project drawer reads both path parameters
A task dialog above the project drawer reads both path parameters

View detail source · View task source

Return navigation and leave confirmation

Return to the parent and preserve query parameters

Try the draft dialog from /projects?q=Harbor: New draft opens /projects/new?q=Harbor. Enter a name and select Preview draft, then Finish preview to return to /projects?q=Harbor with the search preserved. These actions do not create a project.

The static new child route opens a draft form
The static new child route opens a draft form
Draft preview with the action that closes the dialog
Draft preview with the action that closes the dialog

The complete form gets close() from useRouteOverlay() inside a component rendered in the dialog:

TSX
// Call this inside a button component rendered within RouteDialog.
const { close } = useRouteOverlay();

<Button onClick={() => {
  onFinish(); // Clear the draft dirty flag in this example.
  void close();
}}>
  {t('demo.finishPreview')}
</Button>

close() returns to the matched parent route and preserves the query, avoiding assumptions about the last URL segment. The close icon, Escape and backdrop use the same close flow. For ordinary programmatic navigation, see React Router's useNavigate().

View source

Confirm before leaving unsaved changes

After entering a name, select Close. Discard this unsaved draft? lets you keep editing or discard and return to the list:

TSX
// client/pages/projects/new.tsx (excerpt)
const dirtyRef = useRef(false);
const pendingDecisionRef = useRef<{
  promise: Promise<boolean>;
  resolve: (allowed: boolean) => void;
} | null>(null);
const [confirmOpen, setConfirmOpen] = useState(false);

const canLeave = useCallback((): boolean | Promise<boolean> => {
  if (!dirtyRef.current) return true;
  if (!pendingDecisionRef.current) {
    let resolve!: (allowed: boolean) => void;
    const promise = new Promise<boolean>((done) => { resolve = done; });
    pendingDecisionRef.current = { promise, resolve };
    setConfirmOpen(true);
  }
  return pendingDecisionRef.current.promise;
}, []);

useNavigationGuard(canLeave);
// RouteDialog also receives canLeave as beforeClose.
// AlertDialog buttons call decide(false) or decide(true).
const decide = (allowed: boolean) => {
  setConfirmOpen(false);
  if (allowed) dirtyRef.current = false;
  pendingDecisionRef.current?.resolve(allowed);
  pendingDecisionRef.current = null;
};
useEffect(() => () => pendingDecisionRef.current?.resolve(false), []);

The same asynchronous decision is passed to RouteDialog.beforeClose and useNavigationGuard(). They cover overlay close and application navigation, including browser history traversal. The default template places NavigationGuardProvider outside the routes. Returning false blocks departure, true allows it, and a Promise waits for the choice.

While confirmation is open, overlapping requests share one Promise so a single choice settles every waiter without overwriting a callback. Resolve any pending request with false on unmount. Clear the dirty flag when allowing departure to avoid a second confirmation during the close navigation.

The full implementation also handles beforeunload for reloads and leaving the site. The browser supplies that native confirmation text; application navigation guards do not replace it.

An asynchronous navigation guard waits for the discard decision
An asynchronous navigation guard waits for the discard decision

View source

A route's navigation creates its menu entry. A pathless Projects group organizes the list; omitting the complete page declaration, its group looks like this:

TypeScript
{
  name: 'business',
  navigation: { title: 'demo.business', order: 10 },
  children: [
    // Place the projects page declaration here.
  ],
}

Reports uses an Insights group with the /reports prefix. A group has no component and organizes its children without needing its own Outlet:

TypeScript
{
  name: 'reportsGroup',
  path: '/reports',
  navigation: { title: 'demo.insights', order: 20 },
  children: [
    {
      name: 'reports',
      path: '/',
      authz: 'skip',
      navigation: { title: 'demo.reports', icon: ChartColumn },
      componentLoader: () => import('../reports/index.js'),
      children: [
        { name: 'reportSummary', path: 'summary',
          componentLoader: () => import('../reports/summary.js') },
        { name: 'reportOwners', path: 'owners',
          componentLoader: () => import('../reports/owners.js') },
      ],
    },
  ],
}

The child's path: '/' lands at the group address /reports. The group itself does not claim a page address. Only navigation creates a menu entry: details and tasks remain accessible through record links without adding menus.

title is text or a translation key; icon is a React component such as a Lucide icon, not a string or JSX element. order is a finite number, defaults to 0, and sorts siblings in ascending order. Group headings do not show icons. A nested task keeps Project list selected. Authorization hides inaccessible pages and empty groups.

Pathless and prefixed groups, with additional pages under Insights
Pathless and prefixed groups, with additional pages under Insights

View source

Static and dynamic breadcrumbs

breadcrumb and usePageBreadcrumb() connect route metadata and page content to the application template breadcrumb.

breadcrumb: { title: 'demo.workspace' } supplies a static route title. Once the project is available, usePageBreadcrumb() replaces it with the project name:

TSX
// client/pages/projects/workspace.tsx (excerpt)
usePageBreadcrumb(
  project
    ? [
        {
          label: t('demo.projects'),
          to: { pathname: '/projects', search: location.search },
        },
        { label: project.name },
      ]
    : undefined,
);

label is display text and to is an optional destination. The final item is not a link. Pass undefined or null to use the default route breadcrumb. The innermost active declaration takes precedence; unmounting restores the outer declaration.

The screenshot under Child pages that cover parent content shows Project list → Harbor launch. Selecting Project list returns with q=Harbor. The template remembers queries from visited ancestors in the current hierarchy, but a deep link or reload may lack that history. Specify to explicitly when returning with a query must work in those cases.

View source

Authentication and page permissions

Sign-in requirements and page layouts

The route definitions demonstrate all three auth values in separate route trees:

TypeScript
// Three independent routes, not a parent/child tree.
{ name: 'projects', path: '/projects', auth: 'required', /* ... */ }
{ name: 'welcome', path: '/welcome', auth: 'guest', authz: 'skip', /* ... */ }
{ name: 'publicProjects', path: '/public-projects', auth: 'optional', authz: 'skip', /* ... */ }
UsageActionDefault template behavior
requiredOpen /projects in a signed-out windowRedirects to /login; signed-in pages use the application layout with its sidebar
guestOpen /welcome while signed outShows the guest welcome page; signed-in visitors are redirected away
optionalOpen /public-projects signed in or outBoth identities can open the standalone layout

A required route sends a signed-out visitor to the login page
A required route sends a signed-out visitor to the login page
A guest route displays its welcome page before sign-in
A guest route displays its welcome page before sign-in
An optional route is available without signing in and uses a standalone layout
An optional route is available without signing in and uses a standalone layout

Root routes default to required. Descendants inherit auth and cannot change it to another value. Authentication alone does not grant page access.

The current template redirects a protected visit to /login without automatically carrying the original destination. A guest page visited while signed in uses a safe in-app redirect query or returns home. For example, /welcome?redirect=%2Freports%2Fowners sends a signed-in visitor to Owners. Do not assume arbitrary deep links automatically resume after sign-in.

View source

Permission declarations, inheritance and denied access

The complete routes use these authorization declarations:

TypeScript
// Project list and children without their own authorization declaration
 authz: { resource: { type: 'page', id: 'projects' }, action: 'access' }
// The draft page requires another page grant
 authz: { resource: { type: 'page', id: 'project-drafts' }, action: 'access' }
// Reports skip their own page authorization check but still require sign-in
 authz: 'skip'
// Administrator notes require an unrestricted identity
 authz: 'unrestricted'

In System settings → Permission management → Roles and permissions, create a Project viewer role granting only project page access. Create a demonstration user in Users and assign that role. Sign in with a separate browser session and follow the README to verify:

  • The list, details, tasks and workspace are accessible. A child without its own authz inherits the nearest ancestor page's effective value.
  • New draft is hidden and /projects/new is denied. A child's own grant does not replace the parent's check.
  • Reports remain available through skip, while still requiring sign-in.
  • The administrator menu is hidden and /admin-notes/child is denied. The child's skip cannot bypass its parent's unrestricted requirement.

A project viewer can use the list without draft or administrator controls
A project viewer can use the list without draft or administrator controls
Project access alone is insufficient to open a new draft
Project access alone is insufficient to open a new draft
A child with skip cannot bypass an unrestricted parent
A child with skip cannot bypass an unrestricted parent

An administrator can open Administrator notes → Open child page. unrestricted means an identity with unrestricted access, not every signed-in user.

An unrestricted account can open the administrator parent and child
An unrestricted account can open the administrator parent and child

With no ancestor page to inherit from, an omitted authz defaults to unrestricted for required, or skip for guest and optional. Declare it explicitly on the first page of each tree. Pure groups cannot declare authz.

resource.type, resource.id and action must be nonempty strings. Route names and permission IDs are separate; saved role grants refer to the resource ID. Pages without a navigation or breadcrumb title need a readable name in page-permission-titles.ts, such as projectCreate: 'demo.newDraft'. useCan() controls buttons for the same permission. Frontend page grants do not secure APIs or data bundled into the client. This example's project data is public fiction; see authentication, permissions and data scope for business resources and server enforcement.

View source

Route composition, attachment and overrides

Attach within and across packages

Open Export instructions under Insights at /reports/exports. Another contribution attaches it through parent: 'reportsGroup':

TypeScript
export const appendedRoutes = defineAppRoutes([
  {
    parent: 'reportsGroup',
    name: 'reportExports',
    path: 'exports',
    authz: 'skip',
    navigation: { title: 'demo.exports', order: 10 },
    componentLoader: () => import('../examples/exports.js'),
  },
]);

client/routes.ts deliberately collects appendedRoutes before projectRoutes, showing that the target may be declared later. In a larger application, place contributions in separate files and collect them in a flat array.

A separate same-package contribution appears under Insights
A separate same-package contribution appears under Insights

reporting-plugin.ts is a client contribution factory kept in this app. @example/project-reporting demonstrates a plugin namespace; it is not a separate npm package to install. Use package:group to attach across packages:

TypeScript
// client/reporting-plugin.ts
{
  parent: 'pages-routes-navigation:reportsGroup',
  name: 'snapshot',
  path: 'snapshot',
  authz: 'skip',
  navigation: { title: 'demo.snapshot', order: 20 },
  componentLoader: () => import('./pages/examples/plugin-original.js'),
}

Attaching this entry to the app's reportsGroup produces /reports/snapshot. The route and translation namespace still belong to the plugin, which registers both locales. The shipped configuration enables a component override. Temporarily clear the override array in client/route-overrides.ts to see the original page below, then restore it.

The original reporting contribution, captured with the component override temporarily cleared
The original reporting contribution, captured with the component override temporarily cleared

parent is allowed only on contribution root entries and must target a group, not a page. Missing targets, cycles and parent inside existing children fail validation. Add page children through children. Siblings sort by navigation.order; equal values keep existing children first, then appended contributions in registration order.

View app route source · View plugin contribution source

Enable routes through plugin options

A plugin's routes can be a synchronous function of its registration options. reporting-plugin.ts uses enabled to decide whether to contribute its page:

TypeScript
// client/reporting-plugin.ts (excerpt)
export default defineClientPlugin<{ enabled?: boolean }>({
  packageName: '@example/project-reporting',
  // The complete file also registers en-US and zh-CN locales.
  routes: (options) => defineAppRoutes(options.enabled === false ? [] : [
    {
      parent: 'pages-routes-navigation:reportsGroup',
      name: 'snapshot',
      path: 'snapshot',
      authz: 'skip',
      navigation: { title: 'demo.snapshot', order: 20 },
      componentLoader: () => import('./pages/examples/plugin-original.js'),
    },
  ]),
});

// Inside the defineClientPlugins array in client/plugins.ts
reportingPlugin({ enabled: true }),

routes(options) is a synchronous registration function returning one contribution or a flat array. It does not run again when React state or the current user changes. To try disabling the contribution, change enabled to false and clear the component override array to [] so it does not target an absent route. Restore both afterward. An isolated test also covers this option.

Disabling the reporting contribution removes Reporting snapshot from Insights
Disabling the reporting contribution removes Reporting snapshot from Insights

View source

Replace page components

The default example displays a custom Reporting snapshot. Target its package:route ID to replace the component:

TypeScript
// client/route-overrides.ts
import { defineClientRouteComponentOverrides } from '@nocobase/app-client/plugins';

export default defineClientRouteComponentOverrides([
  {
    routeId: '@example/project-reporting:snapshot',
    componentEntry: './client/pages/examples/plugin-custom',
    componentLoader: () => import('./pages/examples/plugin-custom.js'),
  },
]);

// client/runtime.ts (excerpt)
import routeComponentOverrides from './route-overrides.js';
const appRuntime = defineAppRuntime({
  // Retain createAppConfig, locales, routes, plugins and other existing options.
  routeComponentOverrides,
});

The runtime does not discover route-overrides.ts automatically: pass it explicitly to defineAppRuntime(). An override preserves the path, authorization, navigation, owning package and children. The component still runs under the original package's translation namespace. componentEntry records the source entry; componentLoader loads the component.

The custom reporting component keeps its original menu entry and URL
The custom reporting component keeps its original menu entry and URL

Temporarily use an empty override array to see the original component, then restore it. Targets must be registered pages, not groups; each ID may be overridden only once. Do not register a duplicate path to replace a page.

View override source · View runtime registration source

Loading states and error handling

Page loading and failures

Try a slow page opens /route-status/loading. This demonstration loader waits 1.2 seconds to expose the template's loading state:

TypeScript
{
  name: 'slowPage',
  path: '/route-status/loading',
  authz: 'skip',
  componentLoader: async () => {
    await new Promise((resolve) => setTimeout(resolve, 1200));
    return import('../examples/loaded.js');
  },
}

The template loading state while the route component loads
The template loading state while the route component loads
Page content after the component loads
Page content after the component loads

Try a page error opens /route-status/error. Its component deliberately throws to demonstrate the ClientRoute error interface. Do not keep this intentional exception in a production page. Reload after fixing the component or network problem. A rejected loader Promise reaches the same error interface.

A component exception displays the error interface and retry action
A component exception displays the error interface and retry action

View loader source · View template error handling source

Handle unmatched addresses

Try an unknown address opens the unregistered /unknown-example. The current app-router.tsx redirects it to the home page. This fallback belongs to the application template; defineAppRoutes() does not accept path: '*'.

The template redirects an unknown address to the example home page
The template redirects an unknown address to the example home page

View source

Route configuration reference

Configuration fields and defaults

FieldPagePure group
nameRequired, unique within its packageRequired, unique within its package
pathRequiredOptional prefix for children
componentLoaderRequiredNot allowed
childrenOptionalRequired; may be empty
navigationOptional; { title, icon?, order? }Required
breadcrumbOptional; { title }Optional
authOptional; roots default to required, descendants inheritOptional; passed to descendants
authzOptional; declare explicitly on the first pageNot allowed
parentOptional, contribution roots onlyOptional, contribution roots only

Names start with a letter or digit and may then contain letters, digits, dots, underscores and hyphens. Titles are strings and icons are components, not per-user configuration callbacks. React Router fields such as index, element, loader, action and errorElement are not fields of this declaration API.

View source

Path rules and conflict checks

  • Top-level page paths start with /. Child paths append to the parent: both new and /new append; the latter does not jump to the root. Repeated and trailing slashes are normalized.
  • Keep queries and hashes out of path. Wildcards *, optional parameters ?, backslashes, and . or .. segments are unsupported.
  • Page addresses are unique across the app and its plugins. Conflicts ignore static segment case and parameter names: /Projects conflicts with /projects, and /:id conflicts with /:projectId. Static new can coexist with :projectId.
  • Names must be unique within a package across files, groups and levels. Different packages may reuse a name, but not a page address.
  • Only the application may contribute /. /login, /register, /forgot-password and /reset-password must use auth: 'guest'.

Invalid definitions stay out of the running app. routing-contract.test.ts reproduces rejection cases in isolation.

Example source and setup

Environment and startup

The example app uses default template 1.0.0-beta.85 and locks @nocobase/app-client to 4.0.0-beta.5. It requires Node.js 24 and pnpm 11.11.0.

Bash
git clone https://github.com/nocobase/docs-examples-v3.git
cd docs-examples-v3
git checkout 2700e75f5ed0d927c0c37b53e4ffdf105961cc52
cd apps/pages-routes-navigation
npm pkg set packageManager=pnpm@11.11.0
pnpm install --frozen-lockfile
pnpm nocobase config init --dialect sqlite
pnpm nocobase config check
pnpm dev

SQLite is the demonstration and verification environment for this example. It needs no separate database service; it is not a routing requirement. To open the app from another device, set the listening address and app.publicOrigin as described in the example README, then open /main/ on that address. The local config.yml defines the initial account under users.initialAdmin.

The home page links to each demo. Projects and tasks are public fictional fixtures. New draft demonstrates routing and form state without saving business records. Users, roles and authentication use the app's real SQLite database.

The example home page links to each routing demo
The example home page links to each routing demo

Verify the example

Run from the example directory:

Bash
pnpm typecheck
pnpm exec vitest run tests/client/client-routes.test.ts tests/client/routing-contract.test.ts tests/client/routing-behavior.test.tsx tests/client/app-locale-coverage.test.ts tests/client/page-permission-titles.test.ts
pnpm build

Client interaction tests use controlled authorization responses to check nested close, query preservation, default tabs, denied access and draft confirmation. They do not replace real-account checks. The README records browser verification, screenshot reproduction commands and the tested environment.

NocoBase docs assistant

Ask anything about NocoBase…

Each question is answered independently, without earlier questions or answers. Include all relevant context.