Declarative Routing
Define routes as React components. No config files, no filesystem conventions.
@farbenmeer/router is a minimal client-side React router. It covers the most common routing needs without any magic — just components, hooks, and TypeScript.
npm install @farbenmeer/routerDeclarative Routing
Define routes as React components. No config files, no filesystem conventions.
Nested Routes
Compose routes hierarchically with automatic parameter inheritance from parent segments.
Path Parameters
Dynamic segments with colon syntax (:id), plus wildcard routes (* and *name).
Immutable Search Params
Update URL search parameters without mutation — each .set() returns a new params object.
Testing-Friendly
Inject a custom location and history into <Router> for fully deterministic tests.
Tiny
No dependencies beyond React. No runtime overhead from a complex matching engine.
import { Router, Route, Link } from "@farbenmeer/router";
function App() { return ( <Router> <nav> <Link href="/">Home</Link> <Link href="/users">Users</Link> </nav>
<Route path="/"> <HomePage /> </Route>
<Route path="/users"> <UsersLayout /> <Route exact> <UsersList /> </Route> <Route path=":id"> <UserProfile /> </Route> </Route> </Router> );}| Hook | Description |
|---|---|
useRouter() | Programmatic navigation via .push() and .replace() |
usePathname() | Current pathname string |
useParams() | Dynamic route parameters from the current segment |
useSearchParams() | Immutable search parameter access and updates |
useHash() | Current URL hash fragment |