Function leptos_router::Route

source ·
pub fn Route<E, F, P>(props: RouteProps<E, F, P>) -> impl IntoView
where E: IntoView, F: Fn() -> E + 'static, P: Display,
Expand description

Describes a portion of the nested layout of the app, specifying the route it should match, the element it should display, and data that should be loaded alongside the route.

§Required Props

  • path: [P]
    • The path fragment that this route should match. This can be static (users), include a parameter (:id) or an optional parameter (:id?), or match a wildcard (user/*any).
  • view: [F]
    • The view that should be shown when this route is matched. This can be any function that returns a type that implements IntoView (like || view! { <p>"Show this"</p> }) or || view! { <MyComponent/> } or even, for a component with no props, MyComponent).

§Optional Props

  • ssr: SsrMode
    • The mode that this route prefers during server-side rendering. Defaults to out-of-order streaming.
  • methods: [&'static [Method]]
    • The HTTP methods that this route can handle (defaults to only GET).
  • data: impl Into<Loader>
    • A data-loading function that will be called when the route is matched. Its results can be accessed with use_route_data.
  • trailing_slash: TrailingSlash
    • How this route should handle trailing slashes in its path. Overrides any setting applied to crate::components::Router. Serves as a default for any inner Routes.
  • children: Children
    • children may be empty or include nested routes.