Module perseus::router

source ·
Expand description

Utilities for working with the router. Note that you should only have to use these when waiting for a page transition in normal use-cases.

Structs

Information about a route, which, combined with error pages and a client-side translations manager, allows the initialization of the app shell and the rendering of a page.
Information about a route, which, combined with error pages and a client-side translations manager, allows the initialization of the app shell and the rendering of a page.
The state for the router. This makes use of RcSignals internally, and can be cheaply cloned.

Enums

The possible outcomes of matching a route in an app.
The possible outcomes of matching a route. This is an alternative implementation of Sycamore’s Route trait to enable greater control and tighter integration of routing with templates. This can only be used if Routes has been defined in context (done automatically by the CLI).
The current load state of the router. You can use this to be warned of when a new page is about to be loaded (and display a loading bar or the like, perhaps).

Functions

Determines the template to use for the given path by checking against the render configuration, also returning whether we matched a simple page or an incrementally-generated one (true for incrementally generated). Note that simple pages include those on incrementally-generated templates that we pre-rendered with build paths at build-time (and are hence in an immutable store rather than a mutable store).
A version of get_template_for_path that accepts an ArcTemplateMap<G>. This is used by match_route_atomic, which should be used in scenarios in which the template map needs to be passed between threads.
Matches the given path to a RouteVerdict. This takes a TemplateMap to match against, the render configuration to index, and it needs to know if i18n is being used. The path this takes should be raw, it may or may not have a locale, but should be split into segments by /, with empty ones having been removed.
A version of match_route that accepts an ArcTemplateMap<G>. This should be used in multithreaded situations, like on the server.