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

browser-metro

v1.0.8

Published

A browser-based JavaScript/TypeScript bundler with HMR support, inspired by Metro. Runs entirely client-side.

Readme

browser-metro

A browser-based JavaScript/TypeScript bundler inspired by Metro (React Native's bundler). It runs entirely client-side in a Web Worker with HMR, React Refresh, Expo Router, and source map support.

Part of reactnative.run - try the playground.

Features

  • VirtualFS - in-memory filesystem, no real FS needed
  • Module resolution - Node.js-style with configurable extensions
  • Sucrase transforms - fast TypeScript/JSX compilation
  • Plugin system - pre/post transform hooks, module aliases, shims
  • HMR - hot module replacement with React Refresh
  • Expo Router - file-based routing with dynamic route HMR
  • API Routes - in-browser +api.ts via fetch interception
  • Source maps - inline combined source maps for accurate errors
  • npm packages - on-demand bundling via ESM server

Install

npm install browser-metro

Quick Start

import {
  Bundler, VirtualFS, typescriptTransformer
} from "browser-metro";
import type { BundlerConfig, FileMap } from "browser-metro";

const files: FileMap = {
  "/index.ts": 'import { greet } from "./utils";\nconsole.log(greet("World"));',
  "/utils.ts": 'export function greet(name: string) { return "Hello, " + name; }',
};

const bundler = new Bundler(new VirtualFS(files), {
  resolver: { sourceExts: ["ts", "tsx", "js", "jsx"] },
  transformer: typescriptTransformer,
  server: { packageServerUrl: "https://esm.reactnative.run" },
});

const code = await bundler.bundle("/index.ts");
// code is a self-executing bundle with inline source map

HMR with React Refresh

import {
  IncrementalBundler, VirtualFS, reactRefreshTransformer
} from "browser-metro";

const bundler = new IncrementalBundler(new VirtualFS(files), {
  resolver: { sourceExts: ["ts", "tsx", "js", "jsx"] },
  transformer: reactRefreshTransformer,
  server: { packageServerUrl: "https://esm.reactnative.run" },
  hmr: { enabled: true, reactRefresh: true },
});

// Initial build
const initial = await bundler.build("/index.tsx");

// On file change - only re-transforms changed files
const result = await bundler.rebuild([
  { path: "/App.tsx", type: "update" }
]);

if (result.hmrUpdate && !result.hmrUpdate.requiresReload) {
  // Send to iframe for hot patching
  iframe.postMessage({
    type: "hmr-update",
    updatedModules: result.hmrUpdate.updatedModules,
    removedModules: result.hmrUpdate.removedModules,
  });
}

API

Bundler

One-shot bundler. Creates a single bundle from an entry file.

const bundler = new Bundler(vfs, config);
const code = await bundler.bundle("/index.ts");

IncrementalBundler

Watch-mode bundler with HMR. Maintains dependency graph and module cache across rebuilds.

const bundler = new IncrementalBundler(vfs, config);
const initial = await bundler.build("/index.tsx");
const update = await bundler.rebuild([{ path: "/App.tsx", type: "update" }]);

VirtualFS

In-memory filesystem.

const vfs = new VirtualFS(files);
vfs.read("/index.ts");      // string | undefined
vfs.write("/new.ts", code);  // create or overwrite
vfs.exists("/index.ts");     // boolean
vfs.list();                  // string[]

BundlerConfig

interface BundlerConfig {
  resolver: { sourceExts: string[] };
  transformer: Transformer;
  server: { packageServerUrl: string };
  hmr?: { enabled: boolean; reactRefresh?: boolean };
  plugins?: BundlerPlugin[];
  env?: Record<string, string>;
}

Transformers

  • typescriptTransformer - TS/JSX via Sucrase
  • reactRefreshTransformer - adds React Refresh + module.hot.accept()
  • createReactRefreshTransformer(base) - wrap a custom transformer with React Refresh

Plugins

interface BundlerPlugin {
  name: string;
  transformSource?(params): { src: string } | null;   // before Sucrase
  transformOutput?(params): { code: string } | null;   // after Sucrase
  resolveRequest?(context, name): string | null;       // custom resolution
  moduleAliases?(): Record<string, string>;            // redirect requires
  shimModules?(): Record<string, string>;              // inline replacements
}

ESM Package Server

browser-metro fetches npm packages from an ESM server that bundles them on-demand with esbuild:

https://esm.reactnative.run/pkg/[email protected]
https://esm.reactnative.run/pkg/react-dom@19/client

Packages are cached after first request. All dependencies are externalized for shared runtime instances. Version pinning via // @externals metadata prevents transitive dependency mismatches.

Documentation

Full docs at reactnative.run/docs:

Author

Built by Sanket Sahu at RapidNative.

License

MIT