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": "b0ceb637005511a9616cf37439fa775e62f40a5a",
"tarball": "https://registry.npmjs.org/0x1-router/-/0x1-router-0.0.4.tgz",
"fileCount": 4,
"integrity": "sha512-wNiJYfuQlvNkacLkXiV/gDybM73iLK4qRoSwDelIZkAibbVXAwboiCoyRLSHWxZIyXOWG+7dNqtu1t3EloxWyA==",
"signatures": [
{
"sig": "MEYCIQD027HCYphP/mu59l0LpXilFJB3yZ0cLaaPY4P7mJ72FAIhAO5+/aywdW58lu81a2M9iXRpAW004wHCyf/mYZiT+l7U",
"keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
}
],
"unpackedSize": 53471
}Observed since 20 Oct, 17:49 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:31ec7209a8cb146eab492be7d6a6c6d1ad4def752e1124635ef51e216b75f8e7