[]previous and next page

@shadow-js/router

The 77 exports of @shadow-js/router: 25 functions, 1 class, 34 interfaces, 13 types and 4 components.

Everything @shadow-js/router exports, from the TSDoc of its entry point.

Functions#

  • createBrowserHistory: A history over window.history with paths (/a/b).
  • createHashHistory: A history over the URL fragment (#/a/b), for hosts that cannot change the path.
  • createMemoryHistory: An in-memory history for tests, servers and non-browser hosts.
  • createRouter: Creates a router.
  • defineRoute: Builds a typed route.
  • defineTemplate: Wraps the component of a _template file so that it remounts whenever the matched path changes.
  • isNotFound: True for a not-found signal.
  • isRedirect: True for a redirect signal.
  • notFound: Control flow: throw the result to report not-found.
  • parseHydrationData: Parses text produced by serializeHydrationData.
  • redirect: Control flow: throw the result to redirect.
  • serializeHydrationData: Hydration data as text for an inline <script type="application/json">.
  • unsafeHref: Marks a run-time path as a navigation target the router may use.
  • useHref: The href of a target, resolved against the current location.
  • useLoaderData: The loader data of the route the component renders under, or of from.
  • useLocation: The current location.
  • useMatch: The match a component renders under, or the one from names.
  • useMatches: Every match on screen, outermost first.
  • useNavigate: A navigate function bound to the router.
  • useNavigation: The state of the navigation in flight, for global spinners and pending indicators.
  • useOptionalRouter: The router the calling component renders under, or undefined outside a RouterProvider.
  • useParams: The params of the route (and its ancestors), as a view with one memo per key: a reader of one key does not rerun when another key changes.
  • useRouter: The router the component renders under.
  • useSearch: The validated search of the route, as a view with one memo per key.
  • useSearchParams: Reads the query of the current location and sets keys of it.

Classes#

  • SearchValidationError: Thrown when the query does not validate: by a Standard Schema, or by a validateSearch function that throws it on purpose.

Interfaces#

Types#

  • AProps: Props of A.
  • HrefOf: Targets accepted by typed navigation: a registered pattern (/posts/:id, used with params), an href that matches one (/posts/${string}), or a RuntimeHref made by unsafeHref for a path that was validated at run time.
  • NavigateArgs: The rest parameters after the target: the options, required when the pattern has required params.
  • NavigateOptionsFor: The options of a navigation to P: the target-independent ones plus the ParamsOption of the pattern.
  • ParamsOption: The params option a target needs.
  • ParamsView: The params a pattern names.
  • PrefetchStrategy: When a link loads its target ahead of a click (the prefetch feature): "none" never, "intent" on hover after a short delay, keyboard focus and touch, "viewport" after the link has been visible for a moment, "render" as soon as the link is on the page.
  • RegisteredPath: The route paths registered with Register, or string when nothing is registered.
  • RouteComponent: A route component.
  • RouteHeadInput: What a route's head returns: one tag, several, or nothing.
  • RouterFeatureId: The names of the features.
  • RuntimeHref: A same-origin path that was chosen at run time (a validated redirect_url, a stored return path).
  • SearchUpdate: A value a search setter accepts: a new value per key, or undefined to remove the key.

components#

  • A: A client-side anchor.
  • Navigate: Navigates when it renders (in the browser).
  • Outlet: Renders the child route of the current depth.
  • RouterProvider: Makes a router available to the subtree and loads the current location.