Skip to main content
Ends the run and opens another action or a folder’s page in the same browser tab, e.g. the detail of the record the action just created, or the table it was added to.

Usage

Import the action you want to open and ask it for its route. Its params are typed by that action’s params schema:
actions/accounts/createAccountAction.ts
The browser opens /actions/accounts/extend_trial?company=Acme+Inc. and Extend trial starts with ctx.params.company filled in.

Redirect to a page

A page has route() too. Import it from the folder’s index.ts; its params are typed by the page’s params schema:
actions/users/inviteUserAction.ts
The browser opens /groups/users?role=member: the Users folder with its page, which gets ctx.params.role.

Routes

action.route() returns the link to that action, an ActionRoute. The same object goes into a table cell, a table’s row menu, a layout’s menuItems and io.display.link, so one action can be opened from a redirect, a table, a button and a link alike:
page.route() returns a PageRoute, the same fields with page instead of action: the folder the page stands for, users. Its label defaults to the page’s name, or the folder’s name in words. All of them take both, and a page opens in the same tab as an action does.
An action or page without a params schema takes no params: clearCacheAction.route(). When every param of its schema is optional, the params can be left out too: createIntegratorAction.route({ label: 'Create integrator' }). route() works once listen() has loaded the actions folder, so call it inside a handler, not at the top of a file.

Behaviour

  • The run ends with the redirect: the run page opens the other action or the page instead of showing a result, and Back skips the finished run.
  • The handler goes on after await ctx.redirect(), but any io call after it throws, like after a cancel, and what it returns is ignored. Put the redirect last.
  • After the run has ended, the call does nothing.