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": "1915c75f490c0b5227bd8a1da672bb295996e6bd",
"tarball": "https://registry.npmjs.org/0x1-router/-/0x1-router-0.0.15.tgz",
"fileCount": 4,
"integrity": "sha512-fdXcaC6mxHgiXCYUie3bHWn4275QbnxinZB5+MZPyggQdSSmP+VSDGyW5KF/vldUUVSykIYSaFsR1Eatq3qc0g==",
"signatures": [
{
"sig": "MEYCIQCKgvh+sbqmPwoXlLYLh0TPLyww/kgiO0s/9ret+qnA/wIhAL1K1mk+hDbVTAMSD/MCCs5TgDfTDeFdZXMfQXfAA1S0",
"keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
}
],
"unpackedSize": 87353
}Observed since 20 Oct, 17:49 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:2a9bcf4132d95f2e5a2d0a9a27ee817167cd711792348221cbd00a66c6e88c94