RouterProvider
Makes a router available to the subtree and loads the current location.
Makes a router available to the subtree and loads the current location. In the browser the
first load starts once the subtree is mounted. On the server nothing starts here: await
router.ready() before rendering, so the markup has its data.
Import#
ts
import { RouterProvider } from "@shadow-js/router";
Signature#
ts
function RouterProvider(props: RouterProviderProps): unknown
Parameters#
| Name | Description |
|---|---|
props |
See RouterProviderProps. |
Returns#
The provided children (an accessor, as every ShadowJS component result).
Throws#
- TypeError when
routerdid not come fromcreateRouter.
Examples#
ts
render(() => <RouterProvider router={router}><Outlet /></RouterProvider>, document.body);