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

next-single-file

v1.0.4

Published

Convert Next.js static export to a single HTML file with hash routing

Downloads

519

Readme

next-single-file

npm version npm downloads Next.js Bun

A CLI tool that transforms a Next.js static export into a single, self-contained HTML file with hash-based routing. Regex-based, zero runtime dependencies.

How it Works

The tool parses your out/ directory, extracts all routes, and bundles everything into one file. All assets (JS, CSS, fonts, images) are inlined as base64 data URIs, and a hash-based router is injected for client-side navigation.

graph TD
    A[Next.js App] -->|next build| B[out/ Directory]
    B -->|Parser| C[Asset Map & Routes]
    C -->|Inliner| D[Data URIs & Bundles]
    D -->|Bundler| E[Single index.html]
    F[Hash Router] -->|Injected| E
    E -->|Browser| G[Hash Navigation]

Features

  • Self-Contained — Zero external dependencies. Fonts, images, and scripts are all inlined.
  • Hash Routing — Automatically converts path navigation to #/hash navigation.
  • Next.js Compatible — Supports Geist fonts, Turbopack, and modern Next.js features.
  • Robust Encoding — Uses Base64 for the internal route map to prevent minification issues.
  • Browser Shims — Polyfills document.currentScript and other APIs Next.js expects.

Installation

bunx next-single-file --input out --output dist/index.html

Or with npm (requires Bun to be installed):

npx next-single-file --input out --output dist/index.html

Usage

1. Configure Next.js for Static Export

Ensure your next.config.js has output: 'export':

/** @type {import('next').NextConfig} */
const nextConfig = {
  output: 'export',
};

module.exports = nextConfig;

[!WARNING]
Purely Client-Side Runtime
This tool generates a standalone bundle with no backend.

  • Server Logic: Features like Server Actions, cookies(), and Middleware are not supported.
  • Dynamic Routes: You must use generateStaticParams for any dynamic paths (e.g., [id].tsx) to ensure they are pre-rendered into the out/ directory before bundling.
  • RSC: React Server Components are supported if they can be statically rendered to HTML at build time.

2. Build Your Next.js App

# Any pkg manager is fine
bun run build

3. Generate Single HTML File

# npx works too, you need bun installed on your system though
bunx next-single-file --input out --output dist/index.html

Use Cases

| Use Case | Description | |----------|-------------| | Portable Demos | Send a fully functional web app as a single email attachment | | Offline Documentation | Create interactive docs that work without internet | | Embedded UIs | Embed Next.js interfaces into desktop apps or dashboards | | Simple Hosting | Host multi-page apps on GitHub Gists or basic file servers |

Benchmark

Performance on the included test Next.js app (averaged over 3 runs):

| Metric | Value | |--------|-------| | Duration | ~392 ms | | Output Size | ~13.9 MB | | Memory Usage | ~77 MB |

Run your own benchmark:

bun run benchmark

Results may vary based on your app size and system. The test app includes 4 routes with images, fonts, and interactivity.

Development

bun install
bun test
bun run build

License

MIT