react-router-jam is a folder-based routing library designed for React Router v7 and Remix applications. It replaces the traditional flat file approach with an intuitive folder-based convention, allowing developers to organize routes naturally. The library is ideal for front-end developers seeking a more modular and scalable routing structure. Its core value lies in simplifying route management through a familiar directory hierarchy, where each folder represents a route segment and special files like page.tsx define the actual views. This approach reduces config clutter and aligns with developer intuition, making route management straightforward and maintainable.
The concrete problem that react-router-jam solves is the disorganization and ambiguity often encountered with flat-file routing systems. In large applications, a single directory filled with numerous route files quickly becomes unmanageable, making it hard to locate related components or understand the hierarchy. Developers frequently struggle with naming collisions and implicit nesting. This library addresses these pains by enforcing a clear folder structure, where each route's associated files can be co-located. The result is a more maintainable codebase, reduced cognitive load, and a scalable pattern that grows naturally with the application, allowing teams to work on separate sections without conflicts.
First major feature group: Core routing conventions. react-router-jam defines routes using specific file names within folders. The index route is represented by page.tsx, nested routes by combining a folder and a page.tsx, and dynamic segments using [param] syntax. Splat routes use [...param] to capture multiple URL segments. Layout routes are created with layout.tsx, wrapping all nested pages and child layouts. Route groups, denoted by _folder prefix, allow organizing files without affecting the URL path. The not-found.tsx file handles unknown paths at any scope. These conventions are explicitly documented with examples, ensuring developers can quickly adopt the system without memorizing complex rules.
Second major feature group: Automatic colocation and ignored file patterns. By default, files that do not match the naming conventions (page, layout, not-found) are automatically ignored during route generation. This allows developers to co-locate components, styles, utilities, and test files directly within route directories without polluting the routing table. To safely include subdirectories like components or hooks, the library provides an ignoredFilePatterns option using minimatch glob patterns for precise control. This flexibility enables a clean separation of route logic from supporting assets while keeping everything organized by feature, reducing the need for separate folders and imports.
admin
Third feature group: Route matching priority and comparisons. react-router-jam resolves routes based on specificity: static routes take precedence over dynamic segments, which in turn have priority over splat routes. Sibling routes are sorted so that specific static paths always outrank dynamic parameters. This deterministic behavior prevents conflicts and makes reasoning about routing straightforward. The library also offers a direct comparison with React Router's built-in fs-routes, highlighting that react-router-jam uses folder-based structures and support for colocation, while the former uses flat files and lacks colocation by default. This comparison helps developers understand the advantages of folder-based organization.
How the product works overall. Integration is straightforward: first, install the package via bun (or npm) with `bun install react-router-jam`. Then, in the app's routes.ts configuration file, import `jamRoutes` from the library and export it as the default route config. The function accepts an options object where you can specify rootDirectory and ignoredFilePatterns. Under the hood, jamRoutes scans the designated routes directory, analyzes the folder and file structure, and automatically generates the appropriate React Router configuration with fully typed routes. The workflow is declarative and requires minimal boilerplate, letting developers focus on building features rather than managing route definitions.
Concrete use cases and outcomes. For a dashboard application with multiple sections (admin, settings, profile), developers can use nested layouts by placing layout.tsx in each folder to share navigation and sidebars. A blog can leverage dynamic segments ([slug]) for individual posts while maintaining a separate route group for marketing pages using _marketing prefix to avoid URL clutter. Not-found routes allow custom 404s per section (e.g., a global 404 and a dashboard-specific 404), enhancing user experience. By ignoring test files and component directories, the library keeps the routing clean while allowing co-location. The outcome is a highly organized, scalable routing structure that is easy to navigate and maintain, reducing development time and errors.
Target users and platform details. react-router-jam is built for React developers using React Router v7 or Remix, particularly those who prefer convention over configuration. It supports TypeScript (.tsx, .ts) and JavaScript (.jsx, .js). The library is runtime-agnostic, compatible with Bun, Node.js, and any bundler that works with React Router. It is open source and free to use, with no paid plans mentioned. The primary takeaway: react-router-jam brings the clarity and organization of folder-based routing to React Router and Remix, making complex routing setups simple and intuitive. Whether building a small app or a large enterprise dashboard, this library provides a solid foundation for route management.
React developers, front-end engineers, and teams building complex SPAs with React Router v7 or Remix who value organized, scalable routing structures. Ideal for projects requiring clear separation of concerns, nested layouts, and modular codebases. Also suited for developers migrating from flat-file systems to folder-based conventions seeking improved maintainability. The library is designed for those who prefer convention over configuration and want to minimize boilerplate while keeping routes intuitive. Beginners can quickly adopt it due to the straightforward documentation and examples.