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 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-router-rsbuild-plugin

v0.0.1

Published

Generate fully-typed React Router v6 route definitions automatically from your file structure.

Readme

react-router-rsbuild-plugin

Generate fully-typed React Router v6 route definitions automatically from your file structure.

🦊 Optimized for use with LynxJS — a native mobile app framework that uses web technologies.
⚠️ Requires react-router@6


✨ Features

  • Automatically maps your file structure into RouteObject[] for react-router
  • Supports nested layouts (_layout.tsx)
  • Live updates using chokidar when files change
  • Clean and idiomatic output: no config necessary per file
  • Works with aliases like @/pages

📦 Installation

npm install react-router react-router-rsbuild-plugin

🛠 Setup

Use this plugin inside your Rsbuild plugin chain.

rsbuild.config.ts

import { reactRouterPlugin } from 'react-router-rsbuild-plugin';

export default {
  plugins: [
    reactRouterPlugin({
      root: './src/pages', // path to your pages folder
      output: './src/generated/_generated_routes.tsx', // where the routes will be saved
      srcAlias: '@/',
      layoutFilename: '_layout.tsx' // optional, default is '_layout.tsx'
    })
  ]
};

📂 Example File Structure

src/
├── pages/
│   ├── _layout.tsx
│   ├── about.tsx
│   ├── index.tsx
│   └── test/
│       ├── _layout.tsx
│       ├── about.tsx
│       └── index.tsx

🧪 Generated Output Example

import RouteComp0 from '@/pages/_layout';
import RouteComp1 from '@/pages/about';
import RouteComp2 from '@/pages/index';
import RouteComp3 from '@/pages/test/_layout';
import RouteComp4 from '@/pages/test/about';
import RouteComp5 from '@/pages/test/index';
import React from 'react';
import { type RouteObject } from 'react-router';

const routes: RouteObject[] = [
  {
    path: '/',
    element: React.createElement(RouteComp0),
    children: [
      {
        index: false,
        path: 'about',
        element: React.createElement(RouteComp1)
      },
      {
        index: true,
        element: React.createElement(RouteComp2)
      },
      {
        path: 'test',
        element: React.createElement(RouteComp3),
        children: [
          {
            index: false,
            path: 'about',
            element: React.createElement(RouteComp4)
          },
          {
            index: true,
            element: React.createElement(RouteComp5)
          }
        ]
      }
    ]
  }
];

export default routes;

⚛️ Usage in App

import { createMemoryRouter, RouterProvider } from 'react-router';
import routes from '@/generated/_generated_routes.tsx';
import React from 'react';

export default function FileRouter(): React.ReactElement {
  if (!Array.isArray(routes) || routes.length === 0) {
    throw new Error("Error: routes is not an array or is empty.");
  }

  const router = createMemoryRouter(routes);
  return <RouterProvider router={router} />;
}

📘 Conventions

  • index.tsx becomes an index route
  • [param].tsx becomes a dynamic route (:param)
  • _layout.tsx wraps all sibling routes

🤖 AI Generation

This README and some parts of the project were generated with the help of AI. If you spot anything incorrect or unclear, feel free to suggest improvements — corrections are welcomed and appreciated!


🚀 Contributing

Pull Requests are warmly welcomed! If you have suggestions, improvements, or new features in mind, feel free to open an issue or submit a PR.


💬 License

MIT