@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 overwindow.historywith 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_templatefile 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 offrom.useLocation: The current location.useMatch: The match a component renders under, or the onefromnames.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, orundefinedoutside aRouterProvider.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 avalidateSearchfunction that throws it on purpose.
Interfaces#
ABaseProps: The props of A that do not depend on its target.BlockedTransition: A blocked transition, as a blocker sees it.BlockerState: What useBlocker returns.FromOptions: Options of the hooks that take a route id.HydrationData: JSON-serializable snapshot of loaded data.HydrationMatch: One loader result in HydrationData.LoaderArgs: Whatloaderreceives: RouteArgs plus the loader deps.LocationView: The current location, app-relative (without the base path).NavigateBaseOptions: The options of a navigation that do not depend on its target: everything exceptparams.NavigateProps: Props of Navigate.NavigateToOptions: Options ofnavigateand of<A>when the target is not a known literal pattern.NavigationView: Navigation in flight.OpenParamsOption: Openparams, for a target whose pattern is not known: any string values.Register: Augmentable registry.RenderedMatch: One entry of the rendered match chain.RouteArgs: WhatbeforeLoadandloaderreceive for a route.RouteCacheOptions: Thecacheoption of a page route.RouteDefinition: A route built with defineRoute.RouteErrorProps: Props passed to a routeerrorcomponent.RouteHeadTag: One head tag a route'sheadreturns.RouteOptions: Options of defineRoute.Router: A router instance.RouterCacheOptions: Loader cache limits.RouterClock: Time source and timers.RouterFeature: An optional capability of a router (scroll restoration, loader caching, head management, ...).RouterOptions: Options of createRouter.RouterPreloadOptions: The options of Router.preload: those of a navigation, plus asignalthat releases the preload when it aborts.RouterProviderProps: Props of RouterProvider.RouterState: Live state of the router, as accessors.RouterWindow: The window a router uses for popstate, scroll events and storage.SearchCodec: Search codec used when building hrefs from search objects.SearchIssue: One problem a search validator found.SearchSetOptions: Options of a search setter.StandardSchemaLike: A Standard Schema v1 object: the~standardmember that every conforming library provides.
Types#
AProps: Props of A.HrefOf: Targets accepted by typed navigation: a registered pattern (/posts/:id, used withparams), an href that matches one (/posts/${string}), or a RuntimeHref made byunsafeHreffor 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 toP: the target-independent ones plus the ParamsOption of the pattern.ParamsOption: Theparamsoption a target needs.ParamsView: The params a pattern names.PrefetchStrategy: When a link loads its target ahead of a click (theprefetchfeature):"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, orstringwhen nothing is registered.RouteComponent: A route component.RouteHeadInput: What a route'sheadreturns: one tag, several, or nothing.RouterFeatureId: The names of the features.RuntimeHref: A same-origin path that was chosen at run time (a validatedredirect_url, a stored return path).SearchUpdate: A value a search setter accepts: a new value per key, orundefinedto 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.