Observed since 20 Oct, 17:26 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
07-navegation-router
- ✅ Instalar el linter - ✅ Crear una forma de hacer MPAs (Multiple Page Application) - ✅ Crea una forma de hacer SPAs (Single Page Applications) - ✅ Poder navegar entre páginas con el botón de atrás - ✅ Crear componente Link para hacerlo declarativo - ✅ C
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.2.0 | runtime |
viteEnvironment{
"local_name": "vite",
"alias": false,
"peer_metadata": null
} | 5.4.1 | development |
eslintEnvironment{
"local_name": "eslint",
"alias": false,
"peer_metadata": null
} | 9.9.0 | development |
vitestEnvironment{
"local_name": "vitest",
"alias": false,
"peer_metadata": null
} | 2.1.1 | development |
globalsEnvironment{
"local_name": "globals",
"alias": false,
"peer_metadata": null
} | 15.9.0 | development |
@swc/cliEnvironment{
"local_name": "@swc/cli",
"alias": false,
"peer_metadata": null
} | ^0.4.1-nightly.20240914 | development |
@swc/coreEnvironment{
"local_name": "@swc/core",
"alias": false,
"peer_metadata": null
} | ^1.7.26 | development |
happy-domEnvironment{
"local_name": "happy-dom",
"alias": false,
"peer_metadata": null
} | 15.7.4 | development |
@eslint/jsEnvironment{
"local_name": "@eslint/js",
"alias": false,
"peer_metadata": null
} | 9.9.0 | development |
@vitest/uiEnvironment{
"local_name": "@vitest/ui",
"alias": false,
"peer_metadata": null
} | ^2.1.1 | development |
@types/reactEnvironment{
"local_name": "@types/react",
"alias": false,
"peer_metadata": null
} | 18.3.3 | development |
@types/react-domEnvironment{
"local_name": "@types/react-dom",
"alias": false,
"peer_metadata": null
} | 18.3.0 | development |
eslint-plugin-reactEnvironment{
"local_name": "eslint-plugin-react",
"alias": false,
"peer_metadata": null
} | 7.35.0 | development |
@testing-library/reactEnvironment{
"local_name": "@testing-library/react",
"alias": false,
"peer_metadata": null
} | 16.0.1 | development |
@vitejs/plugin-react-swcEnvironment{
"local_name": "@vitejs/plugin-react-swc",
"alias": false,
"peer_metadata": null
} | 3.5.0 | development |
eslint-plugin-react-hooksEnvironment{
"local_name": "eslint-plugin-react-hooks",
"alias": false,
"peer_metadata": null
} | 5.1.0-rc.0 | development |
eslint-plugin-react-refreshEnvironment{
"local_name": "eslint-plugin-react-refresh",
"alias": false,
"peer_metadata": null
} | 0.4.9 | development |
reactEnvironment{
"local_name": "react",
"alias": false,
"peer_metadata": null
} | 18.3.1 | peer |
react-domEnvironment{
"local_name": "react-dom",
"alias": false,
"peer_metadata": null
} | 18.3.1 | peer |
Source distribution
{
"shasum": "7784b77c5924873a0095708f8603d959712c2323",
"tarball": "https://registry.npmjs.org/07-navegation-router/-/07-navegation-router-0.0.2.tgz",
"fileCount": 4,
"integrity": "sha512-k3wOiMrV0+WYoYF1P0S9TFlSOmmaD2sAabIOWQa3dIuyMvfEexAQx9NThD0CwV/lCrUNTNVBbGgOvZKwWyAISA==",
"signatures": [
{
"sig": "MEUCIQDdICT79tCtsQpDpHV66sMohXIqzB5MrRe39uD+Hs02YwIgZc8mM89s2OjtXDS+ywdIGmG9is8IOREXWQ2+u1whm3w=",
"keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"
}
],
"unpackedSize": 2892
}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:57cfeb7dca98d3637790e451dec0610e76032925ed2fa4bd11d02c9940f8ddcf