npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@brabander/routing-react-router

v0.5.4

Published

This library was generated with [Nx](https://nx.dev).

Readme

routing-react-router

This library was generated with Nx.

React Router adapter for @brabander/routing-core: typed navigation (useRouting) and typed route param retrieval (useRouteParams) for web apps built on React Router.

Gebruik

1. Routes definiëren

Definieer je routes als een Record<string, string> met as const, zodat TypeScript de exacte routenamen en :param/:param? segmenten kan afleiden:

const routes = {
  home: '/',
  profile: '/profile/:id',
  'profile-edit': '/profile/:id/edit/:tab?',
} as const;

2. Routes registreren op paginacomponenten

Koppel elke route aan een paginacomponent door rawPath als path-prop aan React Router's <Route> te geven. rawPath geeft het pad-patroon terug zoals het in routes staat (dus mét :id/:tab?) — precies het formaat dat de path-prop verwacht. Zo blijft routes de enige bron van waarheid voor elk pad, in plaats van dat het patroon nogmaals hardcoded moet worden bij de route-registratie:

import { Route, Routes } from 'react-router';
import { useRouting } from '@brabander/routing-react-router';

function App() {
  const { rawPath } = useRouting(routes);

  return (
    <Routes>
      <Route path={rawPath('home')} element={<HomePage />} />
      <Route path={rawPath('profile')} element={<ProfilePage />} />
      <Route path={rawPath('profile-edit')} element={<ProfileEditPage />} />
    </Routes>
  );
}

3. Navigeren met useRouting

import { useRouting } from '@brabander/routing-react-router';

const { goTo, path, rawPath, replace, back } = useRouting(routes);

goTo('home'); // geen params nodig
goTo('profile', { id: '42' }); // verplichte param
goTo('profile-edit', { id: '42' }); // optionele tab mag weg
goTo('profile-edit', { id: '42', tab: 'security' }); // beide params
goTo('profile'); // ❌ TypeScript error: id ontbreekt

path('profile', { id: '42' }); // '/profile/42' — bouwt het pad zonder te navigeren
rawPath('profile-edit'); // '/profile/:id/edit/:tab?' — ongeïnterpoleerd patroon
replace('profile', { id: '7' }); // navigeert met history.replace i.p.v. push
back(); // navigate(-1)

4. Route params uitlezen met useRouteParams

import { useRouteParams } from '@brabander/routing-react-router';

// binnen een <Route path="/profile/:id/edit/:tab?"> element
const { id, tab } = useRouteParams(routes, 'profile-edit');
// id: string, tab: string | undefined — getypeerd op basis van de route

routes en de routenaam worden hier alleen gebruikt om het returntype af te leiden; het uitlezen zelf gebeurt via React Router's eigen useParams.

Beide hooks zijn dunne, getypeerde wrappers rond React Router's useNavigate/useParams. De type-logica (RouteParams, buildPath, route-validatie) zit in de framework-agnostische @brabander/routing-core port — zie die package voor de onderliggende implementatie.

Running unit tests

Run nx test routing-react-router to execute the unit tests via Vitest.