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

@bedrockio/router

v0.4.1

Published

A simpler browser router.

Downloads

314

Readme

@bedrockio/router

A simplified browser router for React applications.

Install

yarn install @bedrockio/router

Dependencies

Peer dependencies must be installed:

yarn install react react-dom

Overview

This package provides a streamlined routing solution for React applications that is mostly compatible with react-router-dom but with a simpler API and fewer features. It focuses on essential routing functionality without the complexity of nested routers or Outlet components.

Key features:

  • Simple, flat routing structure
  • Flexible render prop that accepts components or elements
  • Built-in hooks for common routing needs
  • Convenient useQuery hook for query parameters
  • Support for both browser and static (SSR/SSG) routing

Usage

Basic setup with routes:

import { BrowserRouter, Routes, Route } from '@bedrockio/router';

function App() {
  return (
    <BrowserRouter>
      <Routes>
        <Route path="/" render={Home} />
        <Route path="/about" render={About} />
        <Route path="/users/:id" render={UserProfile} />
      </Routes>
    </BrowserRouter>
  );
}

The render prop accepts any renderable element:

// Component reference
<Route path="/" render={Home} />

// Element
<Route path="/" render={<Home />} />

// Inline component
<Route path="/" render={() => <div>Hello</div>} />

Components

BrowserRouter

Provides routing context using the browser's History API.

import { BrowserRouter } from '@bedrockio/router';

function App() {
  return <BrowserRouter>{/* Your app */}</BrowserRouter>;
}

Automatically scrolls to top on navigation and listens to history changes.

StaticRouter

Provides static routing context for server-side rendering (SSR) or static site generation (SSG).

import { StaticRouter } from '@bedrockio/router';

function App({ path }) {
  return <StaticRouter path={path}>{/* Your app */}</StaticRouter>;
}

Routes

Container component that renders the first matching route.

import { Routes, Route } from '@bedrockio/router';

<Routes>
  <Route path="/" exact render={Home} />
  <Route path="/about" render={About} />
  <Route path="/users/:id" render={UserProfile} />
  <Route render={NotFound} />
</Routes>;

Props

  • exact - When true, the route path must match exactly. Useful for the root path.
  • subdomain - Match routes based on subdomain (e.g., subdomain="admin")

Route

Defines a route with a path and component to render.

import { Route } from '@bedrockio/router';

<Route path="/users/:id" render={UserProfile} />;

Props

  • path - The path pattern to match. Supports parameters (:id) and wildcards. If omitted matched everything.
  • render - The component, element, or function to render when matched
  • exact - Whether to match the path exactly
  • subdomain - Subdomain to match

Path Patterns

// Static paths
<Route path="/about" render={About} />

// Parameters
<Route path="/users/:id" render={UserProfile} />

// Optional parameters
<Route path="/posts/:id?" render={Post} />

// Wildcards (catch-all)
<Route path="*" render={NotFound} />

// Shortcut for path="*"
<Route render={NotFound} />

Link

Client-side navigation link.

import { Link } from '@bedrockio/router';

<Link to="/about">About</Link>;

Prevents full page reload and uses the History API for navigation.

NavLink

Navigation link with active state indication.

import { NavLink } from '@bedrockio/router';

<NavLink to="/about" exact>
  About
</NavLink>;

When active, adds data-active="true" and aria-current="page" attributes for styling:

a[data-active] {
  font-weight: bold;
}

Props

  • exact - When true, only highlights when path matches exactly. When false, also highlights for sub-paths.

Redirect

Redirects to a different route.

import { Redirect } from '@bedrockio/router';

<Redirect to="/login" />;

Can use route parameters:

<Routes>
  <Route path="/old/:id" render={<Redirect to="/new/:id" />} />
  <Route path="/new/:id" render={NewPage} />
</Routes>

Hooks

useNavigate

Returns a function to programmatically navigate.

import { useNavigate } from '@bedrockio/router';

function MyComponent() {
  const navigate = useNavigate();

  function handleClick() {
    navigate('/about');
  }

  return <button onClick={handleClick}>Go to About</button>;
}

Navigation Methods

const navigate = useNavigate();

// Push new entry
navigate('/about');
navigate('/about', { foo: 'bar' }); // with state

// Replace current entry
navigate.replace('/about');
navigate.replace('/about', { foo: 'bar' }); // with state

// Navigate through history
navigate.back(); // Go back one entry
navigate.forward(); // Go forward one entry
navigate.go(-2); // Go back 2 entries
navigate.go(1); // Go forward 1 entry
navigate.go(); // Reload current page

useLocation

Returns the current location object.

import { useLocation } from '@bedrockio/router';

function MyComponent() {
  const location = useLocation();

  console.log(location.pathname); // Current path
  console.log(location.search); // Query string
  console.log(location.hash); // Hash fragment
  console.log(location.state); // History state

  return <div>Current path: {location.pathname}</div>;
}

useParams

Returns route parameters as an object.

import { useParams } from '@bedrockio/router';

function UserProfile() {
  const params = useParams();

  return <div>User ID: {params.id}</div>;
}

// Usage: <Route path="/users/:id" render={UserProfile} />

useQuery

Returns an object representing the query parameters of the URL. This object is like URLSearchParams with a few enhancements. First parameters may be accessed with the get method or directly via properties.

import { useQuery } from '@bedrockio/router';

function SearchResults() {
  const query = useQuery();

  return (
    <div>
      Page: {query.page}
      Page: {query.get('page')}
    </div>
  );
}

// URL: /search?page=2

Additionally the query object will perform navigation with the set, delete, and clear methods:

import { useQuery } from '@bedrockio/router';

function SearchResults() {
  const query = useQuery();

  function onTwoClick() {
    query.set('page', '2');
    // Navigates to /search?page=2
  }

  function onNoPageClick() {
    query.delete('page');
    // Navigates to /search
  }

  function onResetClick() {
    query.clear();
    // Navigates to /search
  }

  return (
    <>
      <div onClick={onTwoClick}>Two</div>
      <div onClick={onNoPageClick}>No Page</div>
      <div onClick={onResetClick}>Reset</div>
    </>
  );
}

Differences from React Router

This router is designed to be simpler and more streamlined:

  • No nested routers - Routes are flat, no <Outlet /> component
  • Simpler Route API - Single render prop accepts components, elements, or functions
  • Built-in useQuery - Query parameters as an object without manual parsing
  • Fewer concepts - No loaders, actions, or data routers
  • Lightweight - Smaller bundle size with focused feature set