RE

React Router

@tanstack/react-router

Modern and scalable routing for React applications

Routing
react
location
router
routing
async
async router
typescript
@tanstack/react-router
javascript
npm
Stars
15k
Weekly
0
Open issues
612
Bundle
~60 kB

Installation

npm install @tanstack/react-router

Code example

import { createRouter, createRootRoute, createRoute, RouterProvider, Link } from "@tanstack/react-router";

const rootRoute = createRootRoute({
  component: () => (
    <div>
      <Link to="/">Home</Link>
    </div>
  ),
});

const indexRoute = createRoute({
  getParentRoute: () => rootRoute,
  path: "/",
  component: () => <h1>Home</h1>,
});

const router = createRouter({ routeTree: rootRoute.addChildren([indexRoute]) });

export function Example() {
  return <RouterProvider router={router} />;
}

Pros & cons

Pros

  • Actively maintained by Tanner Linsley
  • 0 weekly downloads. Battle tested
  • First-class TypeScript definitions
  • MIT licensed

Considerations

  • Adds roughly ~60 kB to your bundle
  • Needs client-only rendering in SSR frameworks
  • Not supported in React Native
  • 612 open issues on GitHub

FAQs

Alternatives & similar libraries