You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

file-based-routing-cli

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

file-based-routing-cli

CLI tool for file-based routing in React projects

npmnpm
Version
1.2.1
Version published
Weekly downloads
10
Maintainers
1
Weekly downloads
 
Created
Source

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

📁 File-Based Routing

  • Creates routes based on file names in the pages directory
  • Supports both JavaScript and TypeScript (.jsx and .tsx files)
  • Automatically generates route components with proper naming
  • Handles index routes (pages/index.jsx/)
  • Updates routes automatically when files are added or removed

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:

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

Watch for Changes

fbr watch

This command:

  • Watches the pages directory for file changes
  • Automatically generates route components for new files
  • Updates the routing configuration when files are added or removed
  • 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
│   └── blog/
│       ├── index.jsx  → /blog
│       └── [id].jsx   → /blog/:id

Component Generation

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

export default function About() {
  return (
    <div>
      <h1>About Page</h1>
    </div>
  );
}

Requirements

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

License

MIT

Keywords

react

FAQs

Package last updated on 08 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts