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/browser-plugin

v0.10.1

Published

Browser integration plugin with History API, hash routing, and popstate support

Readme

@real-router/browser-plugin

License: MIT TypeScript

Browser History API integration for Real-Router. Synchronizes router state with browser URL and handles back/forward navigation.

Installation

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

Quick Start

import { createRouter } from "@real-router/core";
import { browserPluginFactory } from "@real-router/browser-plugin";

const router = createRouter([
  { name: "home", path: "/" },
  { name: "products", path: "/products/:id" },
  { name: "cart", path: "/cart" },
]);

// Basic usage
router.usePlugin(browserPluginFactory());

// With options
router.usePlugin(
  browserPluginFactory({
    base: "/app",
  }),
);

await router.start();

Configuration

router.usePlugin(
  browserPluginFactory({
    base: "/app",
    forceDeactivate: true,
  }),
);

router.navigate("products", { id: "123" });
// URL: http://example.com/app/products/123

| Option | Type | Default | Description | | ----------------- | --------- | ------- | ----------------------------------------------------- | | base | string | "" | Base path for all routes (e.g., "/app") | | forceDeactivate | boolean | true | Bypass canDeactivate guards on browser back/forward |

Looking for hash routing? Use @real-router/hash-plugin instead.

See Wiki for detailed option descriptions and examples.


Added Router Methods

The plugin extends the router instance with browser-specific methods (via extendRouter()):

router.buildUrl(name: string, params?: Params): string

Build full URL with base path.
name: string — route name
params?: Params — route parameters
Returns: string — full URL
Wiki

router.buildUrl("users", { id: "123" });
// => "/app/users/123" (with base "/app")

router.matchUrl(url: string): State | undefined

Parse URL to router state.
url: string — URL to parse
Returns: State | undefined
Wiki

router.navigate("page1");
router.navigate("page2");
router.navigate("page3");

// User clicks back twice rapidly
// Plugin ensures router ends at page1
// URL and router state remain synchronized

router.replaceHistoryState(name: string, params?: Params, title?: string): void

Update browser URL without triggering navigation.
name: string — route name
params?: Params — route parameters
title?: string — page title
Returns: void
Wiki

router.replaceHistoryState("users", { id: "456" });

Usage Examples

With Base Path

router.usePlugin(
  browserPluginFactory({
    base: "/app",
  }),
);

router.navigate("users", { id: "123" });
// URL: /app/users/123

Form Protection

router.usePlugin(
  browserPluginFactory({
    forceDeactivate: false,
  }),
);

import { getLifecycleApi } from "@real-router/core/api";

const lifecycle = getLifecycleApi(router);
lifecycle.addDeactivateGuard("checkout", () => (toState, fromState) => {
  return !hasUnsavedChanges(); // false blocks navigation
});

SSR Support

The plugin is SSR-safe with automatic fallback:

// Server-side — no errors, methods return safe defaults
router.usePlugin(browserPluginFactory());
router.buildUrl("home"); // Works
router.matchUrl("/path"); // Returns undefined

Documentation

Full documentation available on the Wiki:


Related Packages

License

MIT © Oleg Ivanov