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

rrgenius

v1.0.197

Published

File-system based routing for React Router, inspired by Next.js App Router

Readme

RRGenius 🧠⚡

File-system based routing for React Router, inspired by Next.js App Router

npm version License: MIT

🚀 Features

  • File-system routing - Create routes based on your file structure
  • Nested layouts - Automatic layout inheritance with <Outlet />
  • Dynamic routes - Support for [id] and [...slug] parameters
  • Loading states - Built-in loading states per route
  • Error boundaries - Error handling for each route
  • 404 pages - Automatic not found pages
  • Layout groups - Use (group) folders for shared layouts
  • Zero configuration - Works out of the box with Vite
  • TypeScript support - Full TypeScript support
  • Code splitting - Automatic lazy loading

🚀 Quick Start

Option 1: Initialize a new project

# npm
npx rrgenius init

# yarn
yarn dlx rrgenius init

# pnpm
pnpm dlx rrgenius init

# bun
bunx rrgenius init

Option 2: Install manually

# npm
npm install rrgenius

# yarn
yarn add rrgenius

# pnpm
pnpm add rrgenius

# bun
bun add rrgenius

⚡ Quick Start

1. Configure Vite

// vite.config.ts
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { fileSystemRouter } from "rrgenius/vite-plugin";

export default defineConfig({
  plugins: [
    react(),
    fileSystemRouter({
      pagesDir: "./src/pages",
    }),
  ],
});

2. Create Router

// src/main.tsx
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { RouterProvider } from "react-router";
import { createFileSystemRouter } from "rrgenius";

const router = createFileSystemRouter();

createRoot(document.getElementById("root")!).render(
  <StrictMode>
    <RouterProvider router={router} />
  </StrictMode>
);

3. Create Pages

src/pages/
├── layout.tsx              # Root layout
├── page.tsx                # Home page (/)
├── produtos/
│   ├── layout.tsx          # Products layout
│   ├── page.tsx            # /produtos
│   ├── novo/
│   │   └── page.tsx        # /produtos/novo
│   └── [id]/
│       ├── page.tsx        # /produtos/123
│       └── editar/
│           └── page.tsx    # /produtos/123/editar
└── (admin)/                # Layout group
    ├── layout.tsx          # Admin layout
    └── dashboard/
        └── page.tsx        # /dashboard

🎯 Examples

Basic Page

// src/pages/produtos/page.tsx
export default function ProdutosPage() {
  return (
    <div>
      <h1>Lista de Produtos</h1>
      <p>Esta é a página de produtos</p>
    </div>
  );
}

Dynamic Route

// src/pages/produtos/[id]/page.tsx
import { useParams } from "react-router";

export default function ProdutoPage() {
  const { id } = useParams();

  return (
    <div>
      <h1>Produto {id}</h1>
      <p>Detalhes do produto {id}</p>
    </div>
  );
}

Layout with Outlet

// src/pages/layout.tsx
import { Outlet } from "react-router";

export default function RootLayout() {
  return (
    <div>
      <header>
        <h1>Minha Aplicação</h1>
        <nav>
          <a href="/">Home</a>
          <a href="/produtos">Produtos</a>
        </nav>
      </header>

      <main>
        <Outlet /> {/* Pages render here */}
      </main>

      <footer>
        <p>&copy; 2024 Minha Aplicação</p>
      </footer>
    </div>
  );
}

📚 Documentation

🛠️ API Reference

createFileSystemRouter()

Creates a React Router instance from your file structure.

import { createFileSystemRouter } from "rrgenius";

const router = createFileSystemRouter();

fileSystemRouter(options)

Vite plugin for file-system routing.

import { fileSystemRouter } from "rrgenius/vite-plugin";

export default defineConfig({
  plugins: [
    fileSystemRouter({
      pagesDir: "./src/pages", // Default: './src/pages'
      debug: false, // Default: false
    }),
  ],
});

🎨 File Conventions

| File | Purpose | Example | | ------------- | -------------- | --------------- | | page.tsx | Route page | /produtos | | layout.tsx | Shared layout | Header/Footer | | loading.tsx | Loading state | Loading spinner | | error.tsx | Error boundary | Error page | | 404.tsx | Not found page | 404 page |

🔧 Advanced Usage

Layout Groups

Use parentheses for layout groups that don't appear in the URL:

src/pages/
├── (admin)/              # Admin group (not in URL)
│   ├── layout.tsx        # Admin layout
│   ├── dashboard/
│   │   └── page.tsx      # /dashboard (not /admin/dashboard)
│   └── usuarios/
│       └── page.tsx      # /usuarios (not /admin/usuarios)
└── (public)/             # Public group
    ├── layout.tsx        # Public layout
    └── sobre/
        └── page.tsx      # /sobre

Dynamic Routes

src/pages/
├── produtos/
│   ├── [id]/
│   │   ├── page.tsx      # /produtos/123
│   │   └── [action]/
│   │       └── page.tsx  # /produtos/123/editar
│   └── [...slug]/
│       └── page.tsx      # /produtos/a/b/c (catch-all)

🤝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments


Made with ❤️ by the React Route Genius community