npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@martin.xyz/react-router-next

v0.0.2

Published

Next.JS File system routing for React Router

Downloads

152

Readme

Next.JS routing convention for React Router V7

Setting up

First install the react-router-next-routes package:

npm i @martin.xyz/react-router-next

Then use it to provide route config in your app/routes.ts file:

import { type RouteConfig } from "@react-router/dev/routes";
import { nextRoutes } from "@martin.xyz/react-router-next";

export default nextRoutes() satisfies RouteConfig;

Why?

React Router already provides a file-system routing library but has a really different philosophy by constructing URLs using filename rather than directory name.

This library offers a file-system routing that is really similar to Next.JS App Router.

[!WARNING] As routing capabilities are different between React Router and Next.JS this is not a drop-in replacement.

Usage

Each folder correspond to an URL segment, and page.tsx correspond to the page for that URL.

app/
├── routes/
│   ├── about/
│   │   └── page.tsx
│   └── page.tsx
└── root.tsx

| URL | Layouts | Page | | -------- | ------- | --------------------------- | | / | | app/routes/page.tsx | | /about | | app/routes/about/page.tsx |

Note that these routes will be rendered in the outlet of app/root.tsx because of nested routing.

Layouts

Each folder can contain a layout.tsx which will become the layout for all elements within this folder.

app/
├── routes/
│   ├── about/
│   │   ├── layout.tsx
│   │   └── page.tsx
│   ├── layout.tsx
│   └── page.tsx
└── root.tsx

| URL | Layouts | Page | | -------- | -------------------------------------------------------- | --------------------------- | | / | app/routes/layout.tsx | app/routes/page.tsx | | /about | app/routes/layout.tsx -> app/routes/about/layout.tsx | app/routes/about/page.tsx |

Note that the difference with Next.JS is that children are rendered using <Outlet />.

Dynamic Segments

You can have dynamic segments using the [segmentName] notation:

app/
├── routes/
│   ├── [userId]/
│   │   ├── layout.tsx
│   │   └── page.tsx
│   ├── layout.tsx
│   └── page.tsx
└── root.tsx

| URL | Layouts | Page | | ------- | ----------------------------------------------------------- | ------------------------------ | | / | app/routes/layout.tsx | app/routes/page.tsx | | /4832 | app/routes/layout.tsx -> app/routes/[userId]/layout.tsx | app/routes/[userId]/page.tsx |

Splat Routes (catch-all)

Splat routes can be defined using the [...] notation:

app/
├── routes/
│   ├── [...]/
│   │   ├── layout.tsx
│   │   └── page.tsx
│   ├── layout.tsx
│   └── page.tsx
└── root.tsx

| URL | Layouts | Page | | ------------------- | -------------------------------------------------------- | --------------------------- | | / | app/routes/layout.tsx | app/routes/page.tsx | | /test | app/routes/layout.tsx -> app/routes/[...]/layout.tsx | app/routes/[...]/page.tsx | | /test/hello/world | app/routes/layout.tsx -> app/routes/[...]/layout.tsx | app/routes/[...]/page.tsx |

[!IMPORTANT] React Router does not have the ability to have named catch-all segments and it is not possible to have nested routes under a splat route.

Route Groups

Route groups allows you to organize your code without changing the URL.

app/
├── routes/
│   ├── (auth)/
│   │   ├── login/
│   │   │   └── page.tsx
│   │   └── layout.tsx
│   ├── (dashboard)/
│   │   ├── page.tsx
│   │   └── layout.tsx
│   └── layout.tsx
└── root.tsx

| URL | Layouts | Page | | -------- | -------------------------------------------------------------- | ---------------------------------- | | / | app/routes/layout.tsx -> app/routes/(dashboard)/layout.tsx | app/routes/(dashboard)/page.tsx | | /login | app/routes/layout.tsx -> app/routes/(auth)/layout.tsx | app/routes/(auth)/login/page.tsx |