Observed since 20 Oct, 17:26 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
07-navegation-router
A lightweight, modern, and powerful React routing library with declarative routing, dynamic parameters, lazy loading, and full browser history support
A lightweight, modern, and powerful React routing library built from scratch. Create single-page applications (SPAs) with declarative routing, dynamic parameters, lazy loading, and full browser history support.
<Router>, <Route>, and <Link> componentspath-to-regexpRouterErrorBoundarynpm install 07-navegation-router
yarn add 07-navegation-router
pnpm add 07-navegation-router
🌐 Full documentation and interactive examples are available on our GitHub Pages site:
The documentation site includes:
import { Router, Route, Link } from "07-navegation-router";
function App() {
return (
<Router>
<nav>
<Link to="/">Home</Link>
<Link to="/about">About</Link>
<Link to="/users/123">User Profile</Link>
</nav>
<Route path="/" Component={Home} />
<Route path="/about" Component={About} />
<Route path="/users/:id" Component={UserProfile} />
<Route path="/404" Component={NotFound} />
</Router>
);
}
function Home() {
return (
<div>
<h1>Home Page</h1>
<Link to="/about">Go to About</Link>
</div>
);
}
function About() {
return (
<div>
<h1>About Page</h1>
<Link to="/">Back to Home</Link>
</div>
);
}
function UserProfile({ routeParams }) {
// Access route parameters
return <h1>User Profile #{routeParams.id}</h1>;
}
function NotFound() {
return <h1>404 - Page Not Found</h1>;
}
<Router>The main container component that enables routing in your application.
<Router defaultComponent={NotFound}>{/* Your routes go here */}</Router>
Props:
defaultComponent (React.Component, optional): Component to render when no route matches (404 handler)routes (Array, optional): Array of route objects for programmatic routingchildren (React.Node): Route components<Route>Defines a route with a specific path and component to render.
Props:
path (string): The URL path pattern (supports parameters like /users/:id)Component (React.Component): The component to render when the path matches<Route path="/products/:id" Component={ProductDetail} />
Route Parameters:
The matched component receives routeParams as a prop:
function ProductDetail({ routeParams }) {
const { id } = routeParams;
return <h1>Product {id}</h1>;
}
<Link>Declarative navigation component for client-side routing without page reloads.
Props:
to (string): The destination pathtarget (string, optional): Link target attribute (e.g., _blank)<a> element<Link to="/about">About Us</Link>
<Link to="/docs" target="_blank">Documentation</Link>
<Link to="/contact" className="nav-link">Contact</Link>
navigate(path)Programmatic navigation function for imperatively changing routes.
import { navigate } from "07-navegation-router";
function handleLogin() {
// Perform login logic
navigate("/dashboard");
}
<RouterErrorBoundary>Error boundary component for catching and handling routing errors gracefully.
Props:
fallback (React.Component | React.Element, optional): Custom error fallback UIchildren (React.Node): Components to wrapimport { Router, Route, RouterErrorBoundary } from "07-navegation-router";
function App() {
return (
<RouterErrorBoundary fallback={<ErrorPage />}>
<Router>
<Route path="/" Component={Home} />
<Route path="/error" Component={BuggyComponent} />
</Router>
</RouterErrorBoundary>
);
}
function ErrorPage({ error, resetError }) {
return (
<div>
<h1>Something went wrong</h1>
<pre>{error.message}</pre>
<button onClick={resetError}>Try again</button>
</div>
);
}
Access route parameters in your components:
import { Router, Route, Link } from "07-navegation-router";
function App() {
return (
<Router>
<Route path="/blog/:slug" Component={BlogPost} />
<Route path="/users/:userId/posts/:postId" Component={UserPost} />
</Router>
);
}
function BlogPost({ routeParams }) {
const { slug } = routeParams;
return <article>Post: {slug}</article>;
}
function UserPost({ routeParams }) {
const { userId, postId } = routeParams;
return (
<div>
User {userId}, Post {postId}
</div>
);
}
Improve performance by code-splitting your routes:
import { lazy, Suspense } from "react";
const Dashboard = lazy(() => import("./pages/Dashboard"));
function App() {
return (
<Router>
<Suspense fallback={<div>Loading...</div>}>
<Route path="/dashboard" Component={Dashboard} />
</Suspense>
</Router>
);
}
Define a default route for unmatched paths:
<Router>
<Route path="/" Component={Home} />
<Route path="/about" Component={About} />
<Route path="/404" Component={NotFound} />
</Router>
Use the navigate function for imperative routing:
import { navigate } from "07-navegation-router";
function LoginForm() {
const handleSubmit = async (e) => {
e.preventDefault();
const success = await login();
if (success) {
navigate("/dashboard");
window.scrollTo(0, 0); // Optional: scroll to top
}
};
return <form onSubmit={handleSubmit}>...</form>;
}
// Navigate with state
function goToProfile() {
navigate("/profile");
// The navigation event is automatically dispatched
}
Protect your routes with error boundaries:
import { RouterErrorBoundary, Router, Route } from "07-navegation-router";
function App() {
return (
<RouterErrorBoundary
fallback={({ error, resetError }) => (
<div>
<h2>Oops! Something went wrong</h2>
<details>
<summary>Error details</summary>
<pre>{error.message}</pre>
</details>
<button onClick={resetError}>Reset</button>
<button onClick={() => navigate("/")}>Go Home</button>
</div>
)}
>
<Router>
<Route path="/" Component={Home} />
<Route path="/risky" Component={RiskyComponent} />
</Router>
</RouterErrorBoundary>
);
}
Full TypeScript definitions are included:
import {
Router,
Route,
Link,
navigate,
RouterErrorBoundary,
} from "07-navegation-router";
import type { RouteParams, RouteComponentProps } from "07-navegation-router";
interface UserProfileProps extends RouteComponentProps {
routeParams: {
id: string;
};
}
const UserProfile: React.FC<UserProfileProps> = ({ routeParams }) => {
return <h1>User {routeParams.id}</h1>;
};
// Type-safe navigation
navigate("/users/123");
navegation-router/
├── src/
│ ├── components/
│ │ ├── Router.jsx # Main router component
│ │ ├── Route.jsx # Route definition component
│ │ ├── Link.jsx # Navigation link component
│ │ ├── ErrorBoundary.jsx # Error boundary component
│ │ ├── Router.test.jsx # Router tests (13 tests)
│ │ ├── Link.test.jsx # Link tests (10 tests)
│ │ └── Route.test.jsx # Route tests (5 tests)
│ ├── utils/
│ │ ├── consts.js # Constants
│ │ ├── getCurrentPath.js # Path utility
│ │ └── navigation.js # Navigation utilities
│ ├── index.jsx # Main entry point
│ └── navigation.js # Navigation exports
├── lib/ # Compiled output (published to npm)
├── docs/ # Documentation site
├── examples/ # Interactive examples
├── benchmarks/ # Performance benchmarks
├── .github/workflows/ # CI/CD pipelines
│ ├── ci.yml # Test & lint automation
│ └── pages.yml # GitHub Pages deployment
├── package.json
├── LICENSE # MIT License
├── CHANGELOG.md # Version history
├── CONTRIBUTING.md # Contribution guidelines
└── README.md
This library is thoroughly tested using:
Test Coverage:
npm run test # Run tests once
npm run test:watch # Watch mode
npm run test:ui # UI mode
npm run bench # Run performance benchmarks
Benchmarks show excellent performance:
Run benchmarks yourself:
npm run bench
# Install dependencies
npm install
# Run development server
npm run dev
# Build the library
npm run prepare
# Run tests
npm run test
Contributions are welcome! Please read our Contributing Guidelines before submitting a Pull Request.
git checkout -b feature/AmazingFeature)npm test)git commit -m 'Add some AmazingFeature')git push origin feature/AmazingFeature)See CONTRIBUTING.md for detailed guidelines.
This project is licensed under the MIT License - see the LICENSE file for details.
Carlos Caño Gómez
path-to-regexp for advanced pattern matchingSee CHANGELOG.md for a detailed version history.
Latest Release: v0.3.1
react, router, routing, spa, single-page-application, navigation, react-router, client-side-routing, declarative-routing, dynamic-routes, lazy-loading, history-api, browser-history, lightweight-router, minimal-router
Visit our Documentation Site for:
Made with ❤️ by Carlos Caño Gómez
If you find this project useful, please consider:
Happy routing! 🚀
Download counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
path-to-regexpEnvironment{
"local_name": "path-to-regexp",
"alias": false,
"peer_metadata": null
} | 8.3.0 | runtime |
@eslint/jsEnvironment{
"local_name": "@eslint/js",
"alias": false,
"peer_metadata": null
} | 9.38.0 | development |
@swc/cliEnvironment{
"local_name": "@swc/cli",
"alias": false,
"peer_metadata": null
} | 0.7.8 | development |
@swc/coreEnvironment{
"local_name": "@swc/core",
"alias": false,
"peer_metadata": null
} | 1.13.5 | development |
@testing-library/reactEnvironment{
"local_name": "@testing-library/react",
"alias": false,
"peer_metadata": null
} | 16.3.0 | development |
@types/reactEnvironment{
"local_name": "@types/react",
"alias": false,
"peer_metadata": null
} | 19.2.2 | development |
@types/react-domEnvironment{
"local_name": "@types/react-dom",
"alias": false,
"peer_metadata": null
} | 19.2.2 | development |
@vitejs/plugin-react-swcEnvironment{
"local_name": "@vitejs/plugin-react-swc",
"alias": false,
"peer_metadata": null
} | 4.1.0 | development |
@vitest/uiEnvironment{
"local_name": "@vitest/ui",
"alias": false,
"peer_metadata": null
} | 3.2.4 | development |
eslintEnvironment{
"local_name": "eslint",
"alias": false,
"peer_metadata": null
} | 9.38.0 | development |
eslint-plugin-reactEnvironment{
"local_name": "eslint-plugin-react",
"alias": false,
"peer_metadata": null
} | 7.37.5 | development |
eslint-plugin-react-hooksEnvironment{
"local_name": "eslint-plugin-react-hooks",
"alias": false,
"peer_metadata": null
} | 7.0.0 | development |
eslint-plugin-react-refreshEnvironment{
"local_name": "eslint-plugin-react-refresh",
"alias": false,
"peer_metadata": null
} | 0.4.24 | development |
globalsEnvironment{
"local_name": "globals",
"alias": false,
"peer_metadata": null
} | 16.4.0 | development |
happy-domEnvironment{
"local_name": "happy-dom",
"alias": false,
"peer_metadata": null
} | 20.0.5 | development |
prop-typesEnvironment{
"local_name": "prop-types",
"alias": false,
"peer_metadata": null
} | ^15.8.1 | development |
viteEnvironment{
"local_name": "vite",
"alias": false,
"peer_metadata": null
} | 7.1.10 | development |
vitestEnvironment{
"local_name": "vitest",
"alias": false,
"peer_metadata": null
} | 3.2.4 | development |
reactEnvironment{
"local_name": "react",
"alias": false,
"peer_metadata": null
} | >=18.0.0 | peer |
react-domEnvironment{
"local_name": "react-dom",
"alias": false,
"peer_metadata": null
} | >=18.0.0 | peer |
Source distribution
{
"integrity": "sha512-jlsVOW5Bs92PbAv7s9c+E2DPyjeCHMSuXLG1vwiMiUljAxvk6wZEDYS1cYSQ/YJtJ6HwV7zegPgeH01pJjsH+w==",
"shasum": "497c959ca76578c191e320e3683f6eaca08462e2",
"tarball": "https://registry.npmjs.org/07-navegation-router/-/07-navegation-router-0.3.3.tgz",
"fileCount": 12,
"unpackedSize": 24259,
"signatures": [
{
"keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U",
"sig": "MEUCIDjXdjqDJvfzt0ZDm8HsA46vYeusDUM108OTuje9MD0zAiEAn60HhZrydvzPO85aSIjXXHB2/JbWLKJ++weT+C54ROw="
}
]
}Shared repository data · GitHub
Public sponsor counts have not been collected. These signals belong to the repository owner.
github · 1 observations shown. Missing days are unknown.
| Date / source period | Value | Observed at |
|---|---|---|
| 2026-10-21 | 0 | 2026-10-21T14:19:16.0387780Z |
Observed since 20 Oct, 17:26 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:2cd84ca7749bebf9d65af0c31601ab2522bf2c45003f74ea84e497ff155013d9