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

file-based-routing-cli

v1.2.3

Published

CLI tool for file-based routing in React projects

Downloads

10

Readme

File-Based Routing CLI for React

A command-line tool that enables file-based routing in React projects, similar to Next.js routing but for standard React applications. This tool automatically generates and manages routes based on your file structure in the pages directory.

Features

🚀 Quick Setup

  • Automatically installs and configures react-router-dom
  • Sets up the necessary routing infrastructure
  • Modifies your App.jsx/tsx to include routing configuration
  • Creates a pages directory for your route components
  • Supports both JavaScript and TypeScript projects

📁 Advanced File-Based Routing

  • Creates routes based on file names in the pages directory
  • Supports dynamic routes with bracket notation ([id].jsx)
  • Route groups with parentheses notation ((auth)/login.jsx)
  • Index routes for clean directory-based routing
  • Automatically generates route components with proper naming
  • Real-time file watching and route updates

Installation

You can install the package globally:

npm install -g file-based-routing-cli

Or use it directly with npx:

npx file-based-routing-cli [command]

Usage

Initialize Your Project

fbr init

This command:

  1. Creates a pages directory
  2. Installs react-router-dom if not present
  3. Sets up the routing configuration
  4. Modifies App.jsx/tsx to include the router

Watch for Changes

fbr watch

This command:

  1. Watches the pages directory for file changes
  2. Automatically generates route components for new files
  3. Updates the routing configuration when files are added or removed
  4. Provides real-time feedback in the terminal

File Structure Example

your-react-app/
├── src/
│   ├── App.jsx
│   └── routing.jsx (auto-generated)
├── pages/
│   ├── index.jsx           → /
│   ├── about.jsx           → /about
│   ├── contact.jsx         → /contact
│   ├── (auth)/
│   │   ├── login.jsx       → /login
│   │   └── register.jsx    → /register
│   ├── (dashboard)/
│   │   ├── settings.jsx    → /settings
│   │   └── profile.jsx     → /profile
│   └── blog/
│       ├── index.jsx       → /blog
│       └── [id].jsx        → /blog/:id

Routing Features

📁 Dynamic Routes

Use bracket notation for dynamic route parameters:

  • pages/blog/[id].jsx/blog/:id
  • pages/user/[userId]/posts/[postId].jsx/user/:userId/posts/:postId

Dynamic route components automatically include useParams hook and parameter display:

// Generated for pages/blog/[id].jsx
import { useParams } from "react-router-dom";

export default function BlogDynamicId() {
  const params = useParams();
  const id = params.id;

  return (
    <div>
      <h1>BlogDynamicId Page</h1>
      <div>
        <h2>Route Parameters:</h2>
        <p>
          <strong>id:</strong> {id}
        </p>
      </div>
    </div>
  );
}

📂 Route Groups

Use parentheses to group routes without affecting the URL structure:

  • pages/(auth)/login.jsx/login (not /auth/login)
  • pages/(dashboard)/settings.jsx/settings (not /dashboard/settings)
  • pages/(marketing)/about.jsx/about (not /marketing/about)

Route groups are perfect for organizing related pages while keeping clean URLs.

🏠 Index Routes

Index files create routes for their parent directory:

  • pages/index.jsx/ (homepage)
  • pages/blog/index.jsx/blog
  • pages/(auth)/index.jsx/ (route groups are ignored)
  • pages/(dashboard)/settings/index.jsx/settings

Component Generation

When you create a new file in the pages directory, the CLI automatically generates a component with this structure:

Component Naming

The CLI generates unique component names based on the file path:

  • pages/about.jsxAbout
  • pages/blog/index.jsxBlogIndex
  • pages/(auth)/login.jsxAuthLogin
  • pages/blog/[id].jsxBlogDynamicId
  • pages/(dashboard)/user/[id].jsxDashboardUserDynamicId

Requirements

  • Node.js 14 or higher
  • React project using npm
  • React Router DOM v6+

License

MIT