Skip to main content
A folder’s index.ts can export a page instead of an action, see Routing. The folder then shows its subfolders and actions in a column on the left and the page on the right. A page puts display components (a table, tiles…) into a layout. It only displays, so there is no form and no Continue button.
The Users page of the demo app: Change role, Invite user and Reset password in a left column; the title with the Invite user and Reset password buttons, tiles with totals and a users table with linked names, role badges and row menus

The Users folder of the demo app: its actions on the left, the page in the basic layout on the right.

A page needs the display components it shows registered in components, see Display components, and a layout to put them in, see Layouts.

Write a page

Export app.definePage() from the folder’s index.ts. The handler returns a layout with the display components in it:
actions/users/index.ts
  • Every display component takes a label, shown as the heading above it (null for none), and its props.
  • Returning just the array, return [io.display.table(…)], puts it into the layout registered as basic.
  • Props are typed by each component’s schema, and the server checks them again before they reach the browser: props that do not fit show an error instead of the page.
  • The handler runs every time someone opens the folder; nothing is kept between visits.
  • The handler gets ctx like an action: ctx.user is who opened the page and ctx.params the query string of the link (/groups/users?role=admin), see Params. ctx.page.slug is the folder the page stands for: users.
  • app.definePage() belongs only in a folder’s index.ts; anywhere else it stops the app at start.
  • Its const ends in Page, usersPage, as an action’s ends in Action; the file stays index.ts.

Params

Describe the query string the page expects with a zod schema in params, as an action does. The server checks the link against it before the handler runs, and ctx.params gets the parsed, typed value:
actions/users/index.ts
  • A link that does not fit shows The link does not fit this page with what is wrong, instead of the page.
  • Without params, ctx.params is every key of the query string as a string.
  • The schema also types usersPage.route(), the link an action opens with ctx.redirect() and a table cell, a row menu, menuItems or io.display.link lists: usersPage.route({ params: { role: 'admin' } }).

Unlisted pages

A page that only makes sense for one record, such as the detail of a user opened from a table or after an action, can stay out of the navigation. Pass unlisted: true: its folder is not a tab or a folder card because of the page, but the page still opens from its URL, from ctx.redirect() and from a link in a table:
actions/userDetail/index.ts
  • Link to it from a table with its route(): { label: user.name, route: userDetailPage.route({ params: { id: user.id } }) } in a cell, or the same route in a row menu.
  • A folder with listed actions is still shown for them, and opening it shows the page as usual.
  • It is not a permission: anyone who can log in can still open its URL.

Order

The folder of a page is a tab or a folder card, alphabetical by name. Pass order to put it higher: folders with an order come first, lower numbers first.
actions/queue/index.ts
The same option orders actions within a folder, see Order.

Layouts

The handler returns the display components inside a layout, the frame that places them. Every layout is a package registered in layouts, the basic one too:
app.ts
See Layout components for the layouts there are and how to write your own.