I built a modern React router because I was tired of existing ones
Routing in React has always felt⦠either too simple or too complicated.
- Some routers feel too minimal β you end up building everything yourself
- Others feel over-engineered β great power, but heavy mental overhead
So I built my own.
π Introducing routexiz β a lightweight, modern router for React with a clean mental model.
π§ The idea: routing as a tree
Instead of thinking in flat routes, routexiz models your app like a tree.
Each route is a node.
Navigation resolves a single path from root to leaf.
route("/", Layout, root => {
root.route("/dashboard", Dashboard, dash => {
dash.guard(authGuard)
dash.middleware(trackPageView)
})
})
This gives you:
- Natural nested layouts
- Predictable execution
- Clear structure as your app grows
β‘ Navigation that understands your route
Instead of this:
navigate("/users/1")
You write:
navigate("/users/:id", {
params: { id: 1 }
})
No string guessing.
No mismatched paths.
π₯ What makes it different?
I focused on combining things I always wanted in one place:
- Suspense-first data loading
- Route-level guards (block navigation)
- Middleware (side effects)
- Prefetch (hover + viewport)
- Loader caching with TTL
- Error boundaries per route
- Built-in transitions
All without making the API complex.
π§© Example: data loading
route("/users/:id", User, {
loader: async ({ params }) => fetchUser(params.id)
})
const data = useLoaderData()
Simple, predictable, and works with React Suspense.
π How is this different?
Very roughly:
- Traditional routers β string-based navigation
- Some modern routers β very powerful, but complex mental model
- routexiz β tries to balance power + simplicity
The goal is not to compete on features alone, but on developer experience and clarity.
π§ Mental model
- Guard β βCan we enter?β
- Middleware β βDo something while enteringβ
This separation keeps things clean as your app grows.
π§ͺ Where I think it shines
From my own usage, this approach feels especially nice when:
- Building dashboards with nested layouts
- Handling auth / permissions cleanly
- Prefetching data for smoother navigation
- Keeping routing logic predictable as the app scales
π§ Current state
Iβve built most of the core features:
- Type-safe params
- Nested routing builder
- Devtools (basic)
- React adapter
- Documentation & examples
Butβ¦
π The ecosystem is still very early.
π Looking for feedback (and contributors)
If this approach resonates with you, Iβd love your feedback:
- What feels intuitive?
- What feels off?
- Whatβs missing for production use?
Even better β try it in a small project and break it π
π Links
- NPM: https://www.npmjs.com/package/routexiz
- Live example: https://codesandbox.io/p/sandbox/2lslks
π§ Final thought
Iβm not trying to replace existing routers overnight.
I just want to explore a simpler, more predictable way to handle routing in modern React.
If that sounds interesting to you β letβs build it together.
π¬ If you're currently using React Router or another solution,
what's the biggest pain point you have with routing today?
Top comments (0)