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)