logologo
Get Started
Guide
Development
Plugins
API
Home
English
简体中文
日本語
한국어
Español
Português
Deutsch
Français
Русский
Italiano
Türkçe
Українська
Tiếng Việt
Bahasa Indonesia
ไทย
Polski
Nederlands
Čeština
العربية
עברית
हिन्दी
Svenska
Get Started
Guide
Development
Plugins
API
Home
logologo
RunJS Overview
Import Modules
Render in Container

Globals

window
document
navigator

ctx

ctx.blockModel
ctx.collection
ctx.collectionField
ctx.dataSource
ctx.dataSourceManager
ctx.element
ctx.exit()
ctx.exitAll()
ctx.filterManager
ctx.form
ctx.getModel()
ctx.getValue()
ctx.getVar()
ctx.i18n
ctx.importAsync()
ctx.initResource()
ctx.libs
ctx.location
ctx.logger
ctx.makeResource()
ctx.message
ctx.modal
ctx.model
ctx.notification
ctx.off()
ctx.on()
ctx.openView()
ctx.render()
ctx.request()
ctx.requireAsync()
ctx.resource
ctx.route
ctx.router
ctx.setValue()
ctx.sql
ctx.t()
ctx.view
Previous Pagectx.route
Next Pagectx.setValue()

#ctx.router

A React Router instance for navigation in flows.

#Type definition

router: Router

Router comes from @remix-run/router.

#Notes

ctx.router provides navigation capabilities in RunJS. Use ctx.router.navigate() to navigate to a path, replace history, or pass state.

#Methods

#ctx.router.navigate()

Navigate to a target path.

Signature:

navigate(to: string | number | null, options?: RouterNavigateOptions): Promise<void>

Parameters:

  • to: target path (string), relative history position (number, e.g. -1 for back), or null (refresh current page)
  • options: optional config
    • replace?: boolean: replace current history entry (default false, i.e. push)
    • state?: any: state passed to target route, not shown in URL; accessible via ctx.location.state

Examples:

// Basic navigation (push history)
ctx.router.navigate('/users');

// Navigate and replace history
ctx.router.navigate('/users', { replace: true });

// Navigate with state
ctx.router.navigate('/users/123', {
  state: { from: 'dashboard' }
});

// Replace with state
ctx.router.navigate('/home', {
  replace: true,
  state: { userId: 123 }
});

#Notes

  • navigate() pushes a new history entry by default
  • replace: true replaces the current entry without adding a new one (useful for redirects)
  • About state:
    • Data passed via state is not in the URL and suits sensitive or temporary info
    • Access it via ctx.location.state
    • It is stored in browser history and is available on back/forward
    • It is lost on page refresh