DEV Community

Delpi Kye
Delpi Kye

Posted on

Rethinking React routing: a simpler, more predictable approach

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)
  })
})
Enter fullscreen mode Exit fullscreen mode

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")
Enter fullscreen mode Exit fullscreen mode

You write:

navigate("/users/:id", {
  params: { id: 1 }
})
Enter fullscreen mode Exit fullscreen mode

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()
Enter fullscreen mode Exit fullscreen mode

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


๐Ÿง  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)