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": "2532d6f8b7fbca2f234fd488939482953663afc1",
"tarball": "https://registry.npmjs.org/0x1-router/-/0x1-router-0.0.16.tgz",
"fileCount": 4,
"integrity": "sha512-3BDnqvqQkszlPi0/BendVr1ENWbgZI96wwFMrszBGFsuYJnRDmrnU59Zkm7SRIPAfarBvnRPdhsa0RyDJv7zoA==",
"signatures": [
{
"sig": "MEUCIQDR5m/imy8bX95dgx7C5gXzEP4deU+GPuyvq3R52AE6fQIgX2Ql8pKe3+At2iOXuBGiwrsjbSMAwRvexVQ5bpzbepE=",
"keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
}
],
"unpackedSize": 95597
}Observed since 20 Oct, 17:49 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:cd5dc6c47a559f9cd5e82c35227f8437ce679d46fefcce89da9826f89936d40e