Router
Raised by @shadow-js/router and @shadow-js/router/core.
Raised by @shadow-js/router and @shadow-js/router/core.
ROUTER_SCROLL_STORAGE#
Warning, every failure (development only). Scroll restoration could not read or write its positions in sessionStorage (storage disabled, quota exceeded, private mode). Navigation continues; positions are not restored after a reload. Scroll restoration is the scrollRestoration() feature (from @shadow-js/router/scroll): leave it out of createRouter({ features }) to turn it off.
PatternSyntaxError#
Not a code but an error class (PatternSyntaxError, exported by @shadow-js/router/core). defineRoute(path) parses the pattern immediately and throws it for: an empty param name (/a/:), a splat that is not the last segment (/files/*rest/x), an empty segment, a duplicate param name, or more than the allowed number of optional segments. Fix: correct the pattern.
Route definition errors#
defineRoute("") without an id throws TypeError: defineRoute: a pathless route needs an explicit id. Two routes with the same id throw defineRoute: route id "x" is used by two routes from createRouter. Two routes that match the same URLs throw Error: route conflicts: one and two (ambiguous-path, /a); the message names the ids, the kind and the pattern.
Unsafe navigation target#
router.navigate(...) refuses targets that are not a path or an http/https URL (javascript:, data:). It resolves with { kind: "error", error } where error is TypeError: unsafe navigation target: "javascript:alert(1)"; resolveLocation from @shadow-js/router/core throws it directly.
Router hooks outside RouterProvider#
useNavigate(), useParams(), useLocation() and the other router hooks throw TypeError: useRouter() must be used inside <RouterProvider> (the message names the hook) when there is no RouterProvider above them. parseHydrationData(text) throws TypeError: parseHydrationData(): not hydration data for text that is not the output of serializeHydrationData.