Current collected state Current
Observed since 20 Oct, 17:49 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
0x1-router
A lightweight, type-safe client-side router for JavaScript and TypeScript applications.
A lightweight, type-safe client-side router for JavaScript and TypeScript applications.
# Using bun
bun add 0x1-router
# Using npm
npm install 0x1-router
# Using yarn
yarn add 0x1-router
import { Link, Route, useRouter } from '0x1-router';
// Navigation with Link component
function Nav() {
return (
<nav>
<Link href="/" className="nav-link">Home</Link>
<Link href="/about" className="nav-link">About</Link>
<Link href="/contact" className="nav-link">Contact</Link>
</nav>
);
}
// Programmatic navigation
function HomePage() {
const { navigate } = useRouter();
const goToAbout = () => {
navigate('/about');
};
return (
<div>
<h1>Home Page</h1>
<button onClick={goToAbout}>Go to About</button>
</div>
);
}
// Route definition and rendering
const router = useRouter();
router.addRoute({
path: '/',
component: HomePage,
exact: true
});
router.addRoute({
path: '/about',
component: AboutPage
});
// Render current route
function App() {
return (
<div>
<Nav />
<Route />
</div>
);
}
LinkJSX component for navigation links.
Props:
href: string - The target pathclassName?: string - CSS class namechildren: any - Link contentRouteRenders the component for the current route.
useRouter()Returns router utilities:
navigate(path: string) - Navigate to a pathcurrentPath: string - Current route pathaddRoute(route: Route) - Add a route definitiongetCurrentRoute() - Get current route objectRouteinterface Route {
path: string;
component: () => JSX.Element;
exact?: boolean;
}
MIT
Download counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
typescriptEnvironment{
"local_name": "typescript",
"alias": false,
"peer_metadata": null
} | ^5.4.5 | development |
Source distribution
{
"shasum": "a7579f9a9b89105e3077eaed5c6dd89a4293322e",
"tarball": "https://registry.npmjs.org/0x1-router/-/0x1-router-0.0.5.tgz",
"fileCount": 4,
"integrity": "sha512-iltw79JwSK7kl7fMTNzMSldIoRUSoJxZbi5KDDJkBuVqerDidEzJWwlJc7ZFj93iTiaWr5HvfuLGtQWWT8T+2A==",
"signatures": [
{
"sig": "MEUCIQCV72RVy6B8mzjcfyiy9lEoLqA+0M0y0Uhp0SXiCUcNeQIgEzpXoFcZLYU4PJCCXk1+nnP3iTZhk3pr9s1RCtUo7CE=",
"keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
}
],
"unpackedSize": 56921
}Observed since 20 Oct, 17:49 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:cd8b4b3ca2ff3aa726445288817c720651ef64cc15cd40babb08beadcaf106c9