The current route matching information, corresponding to the route concept in React Router. It is used to retrieve the current matching route configuration, parameters, and more. It is typically used in conjunction with ctx.router and ctx.location.
| Scenario | Description |
|---|---|
| JSBlock / JSField | Perform conditional rendering or display the current page identifier based on route.pathname or route.params. |
| Linkage Rules / FlowEngine | Read route parameters (e.g., params.name) for logic branching or to pass them to child components. |
| View Navigation | Internally compare ctx.route.pathname with a target path to determine whether to trigger ctx.router.navigate. |
Note:
ctx.routeis only available in RunJS environments that contain a routing context (such as JSBlocks within a page, Flow pages, etc.). It may be null in pure backend or non-routing contexts (such as background workflows).
| Field | Type | Description |
|---|---|---|
pathname | string | The full path of the current route, consistent with ctx.location.pathname. |
params | Record<string, any> | Dynamic parameters parsed from the route template, such as { name: 'users' }. |
path | string | The route template, such as /admin/:name. |
name | string | Unique route identifier, commonly used in multi-tab or multi-view scenarios. |
| Purpose | Recommended Usage |
|---|---|
| Read current path | ctx.route.pathname or ctx.location.pathname; both are consistent during matching. |
| Read route parameters | ctx.route.params, e.g., params.name representing the current page UID. |
| Navigation | ctx.router.navigate(path) |
| Read query parameters, state | ctx.location.search, ctx.location.state |
ctx.route focuses on the "matched route configuration," while ctx.location focuses on the "current URL location." Together, they provide a complete description of the current routing state.
ctx.router.navigate() changes the path, ctx.route will update accordingly.ctx.route.