Skip to content

Route

Defined in: route.ts:8

The class for the global route object.

path: string

Defined in: route.ts:10

The current path of the URL as a string. For instance "/" or "/users/123/feed". Paths are normalized to always start with a / and never end with a / (unless it’s the root path).


p: string[]

Defined in: route.ts:12

An convenience array containing path segments, mapping to path. For instance [] (for "/") or ['users', '123', 'feed'] (for "/users/123/feed").


hash: string

Defined in: route.ts:14

The hash fragment including the leading #, or an empty string. For instance "#my_section" or "".


search: Record<string, string>

Defined in: route.ts:16

The query string interpreted as search parameters. So "a=x&b=y" becomes {a: "x", b: "y"}.


state: Record<string, any>

Defined in: route.ts:18

An object to be used for any additional data you want to associate with the current page. Data should be JSON-compatible.


depth: number

Defined in: route.ts:20

The navigation depth of the current session. Starts at 1. Writing to this property has no effect.


nav: NavType

Defined in: route.ts:28

The navigation action that got us to this page. Writing to this property has no effect.

  • "load": An initial page load.
  • "back" or "forward": When we navigated backwards or forwards in the stack.
  • "go": When we added a new page on top of the stack.
  • "push": When we added a new page on top of the stack, merging with the current page. Mostly useful for page transition animations. Writing to this property has no effect.