nano-kit-react-router
Installation
SKILL.md
@nano_kit/react-router
@nano_kit/router is a small signal-based router: the current location is a signal, routes are a typed table, pages and layouts are matched into a page signal, and links, head tags and scroll are utilities on top. @nano_kit/react-router re-exports it and adds the React pieces. Signals, stores and DI are described in the nano-kit-store skill, component bindings in nano-kit-react.
Reference
DOCS.md next to this file is the documentation of the released packages as published on https://nano-kit.js.org, generated from the site sources. Read it for the route syntax, tokens, hooks, components and descriptors before writing code. This skill adds only conventions, choices and pitfalls.
Setup contract
- Declare the route table once,
as const, and augmentAppContext.routesexactly once, soLocation$,Navigation$,Paths$andLinkare typed by it. - Provide
LocationNavigation$(frombrowserNavigation(routes)),Page$(fromrouter($location, pages)) andPages$together at the root; the derived tokens come for free. - Render with the ready-made
App, let layouts render children throughOutlet, and calluseSyncHead(),useLinkComponentPreload()anduseLinkComponentAriaCurrent()once in the root layout. - Page modules export the component as
defaultand, when needed,Stores$(what SSR awaits and dehydrates),Head$(head descriptors) andstatusCode.