Catalog npm
Back to packageRELEASE DETAILS

0.0.7

npm

0x1-router

A lightweight, type-safe client-side router for JavaScript and TypeScript applications.

Published29 May 2025
Direct dependencies1
Transitive dependenciesNot calculated

README

Current package documentation

0x1-router

A lightweight, type-safe client-side router for JavaScript and TypeScript applications.

Features

  • 🌐 Simple client-side routing
  • 🔒 Type-safe with full TypeScript support
  • 📦 JSX-compatible Link component
  • 🪝 React-style hooks API
  • 🪶 Tiny footprint with zero dependencies
  • 🎯 History API integration

Installation

# Using bun
bun add 0x1-router

# Using npm
npm install 0x1-router

# Using yarn
yarn add 0x1-router

Basic Usage

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>
  );
}

API Reference

Components

JSX component for navigation links.

Props:

  • href: string - The target path
  • className?: string - CSS class name
  • children: any - Link content

Route

Renders the component for the current route.

Hooks

useRouter()

Returns router utilities:

  • navigate(path: string) - Navigate to a path
  • currentPath: string - Current route path
  • addRoute(route: Route) - Add a route definition
  • getCurrentRoute() - Get current route object

Types

Route

interface Route {
  path: string;
  component: () => JSX.Element;
  exact?: boolean;
}

License

MIT

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 1

Native requirements
1 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
^5.4.5development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "125c90803c74f1224482bad97abf21f4f6755727",
  "tarball": "https://registry.npmjs.org/0x1-router/-/0x1-router-0.0.7.tgz",
  "fileCount": 4,
  "integrity": "sha512-B8XPHsblzX1wfMd9OSXoxvZMr5z/+h/Prsa8GD6JNtE+/fay7sBoa8k91GDECGwT5XIpjyAcbIHZfHXH6981Bg==",
  "signatures": [
    {
      "sig": "MEQCIHNScq1xNkEbq86qOsDRLEJeR70JxbhSbLKhrDaBwKBzAiAUb0bnEmDf+RhlkPpm2FnOOpTlISMydSJxzEIAnDXIHQ==",
      "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
    }
  ],
  "unpackedSize": 59158
}

Repository

PENDING
triex/0x1

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 17:49 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:1b6d669be9f490297e294f072973232e8ba4e28ee549165b8fd52cd8da12743c

Other collected versions

0.0.2025 Jun0.0.1824 Jun0.0.1710 Jun0.0.166 Jun0.0.155 Jun0.0.145 JunView all collected versions →