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

@real-router/react

v0.4.5

Published

React integration for Real-Router

Readme

@real-router/react

License: MIT React

React integration for Real-Router — hooks, components, and context providers.

Installation

npm install @real-router/react @real-router/core @real-router/browser-plugin
# or
pnpm add @real-router/react @real-router/core @real-router/browser-plugin
# or
yarn add @real-router/react @real-router/core @real-router/browser-plugin
# or
bun add @real-router/react @real-router/core @real-router/browser-plugin

Peer Dependencies: react >= 18.0.0

Quick Start

import { createRouter } from "@real-router/core";
import { browserPluginFactory } from "@real-router/browser-plugin";
import { RouterProvider, useRoute, Link } from "@real-router/react";
import { createRoot } from "react-dom/client";

// Define routes
const routes = [
  { name: "home", path: "/" },
  {
    name: "users",
    path: "/users",
    children: [{ name: "profile", path: "/:id" }],
  },
];

// Create and configure router
const router = createRouter(routes);
router.usePlugin(browserPluginFactory());
router.start();

// App component
function App() {
  const { route } = useRoute();

  return (
    <div>
      <nav>
        <Link routeName="home">Home</Link>
        <Link routeName="users">Users</Link>
      </nav>
      <main>
        <h1>Current route: {route?.name}</h1>
      </main>
    </div>
  );
}

createRoot(document.getElementById("root")!).render(
  <RouterProvider router={router}>
    <App />
  </RouterProvider>,
);

API

Provider

<RouterProvider router={router}>

Provides router instance to component tree via React Context.
router: Router — router instance from createRouter()
children: ReactNode — child components
Wiki

<RouterProvider router={router}>
  <App />
</RouterProvider>

Hooks

useRouter(): Router

Get router instance. Never re-renders on navigation.
Returns: Router — router instance
Wiki

import { useRouter } from "@real-router/react";

const NavigateButton = () => {
  const router = useRouter();

  return <button onClick={() => router.navigate("home")}>Go Home</button>;
};

useRoute(): { router, route, previousRoute }

Get current route state. Re-renders on every navigation.
Returns: { router: Router, route: State | undefined, previousRoute: State | undefined }
Wiki

import { useRoute } from "@real-router/react";

const CurrentRoute = () => {
  const { router, route, previousRoute } = useRoute();

  return (
    <div>
      <p>Current: {route?.name}</p>
      <p>Previous: {previousRoute?.name}</p>
      <p>Params: {JSON.stringify(route?.params)}</p>
      <button onClick={() => router.navigate("home")}>Go Home</button>
    </div>
  );
};

useRouteNode(nodeName: string): { router, route, previousRoute }

Optimized hook for nested routes. Re-renders only when specified node changes.
nodeName: string — route segment to observe (e.g., "users") Returns: { router: Router, route: State | undefined, previousRoute: State | undefined }
Wiki

import { useRouteNode } from "@real-router/react";

const UsersSection = () => {
  // Only re-renders when routes starting with "users" change
  const { router, route, previousRoute } = useRouteNode("users");

  // route is undefined when current route is NOT under "users" node
  if (!route) {
    return null;
  }

  switch (route.name) {
    case "users":
      return <UsersList />;
    case "users.profile":
      return <UserProfile id={route.params.id} />;
    default:
      return null;
  }
};

Components

<Link routeName={string} routeParams={object} ...props>

Navigation link with automatic active state detection.
routeName: string — target route name
routeParams?: Params — route parameters
routeOptions?: { reload?, replace? } — navigation options
activeClassName?: string — class when active (default: "active") activeStrict?: boolean — exact match only (default: false) ignoreQueryParams?: boolean — ignore query params in active check (default: true)
Wiki

import { Link } from "@real-router/react";

<Link
  routeName="users.profile"
  routeParams={{ id: "123" }}
  activeClassName="active"
  activeStrict={false}
>
  View Profile
</Link>;

<ConnectedLink ...props>

Same as Link, but re-renders on every route change.
Props: same as Link
Wiki

<BaseLink router={router} ...props>

Low-level link component. Requires router instance as prop.
router: Router — router instance
Props: same as Link
Wiki


Migration from react-router5

| API | react-router5 | @real-router/react | | --------------------------------------------- | ------------- | ------------------ | | RouterProvider | ✓ | ✓ | | Link, ConnectedLink, BaseLink | ✓ | ✓ | | useRouter, useRoute, useRouteNode | ✓ | ✓ | | withRouter, withRoute, routeNode | ✓ | ❌ Use hooks | | Router, Route, RouteNode (render props) | ✓ | ❌ Use hooks |


Related Packages

License

MIT © Oleg Ivanov