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

@kingironman2011/vite-pages

v1.0.2

Published

Vite plugin that auto-generates HTML files for every react-router-dom route so refreshing on a sub-page never 404s (great for GitHub Pages, Netlify, Vercel static, etc.)

Readme

@kingironman2011/vite-pages

Never get a 404 on page refresh again.
A Vite plugin that auto-generates an index.html for every route detected in your React Router app — perfect for GitHub Pages, Netlify static, and any host that doesn't support server-side routing.


The problem

When you deploy a React SPA (with react-router-dom) to a static host like GitHub Pages, visiting /about directly or refreshing on it causes a 404. The host looks for /about/index.html on disk — which doesn't exist.

The solution

@kingironman2011/vite-pages hooks into your Vite build. After the bundle is written it:

  1. Scans your source files for every route path registered in react-router-dom (JSX <Route path="…"> and createBrowserRouter object syntax)
  2. Creates {route}/index.html inside your dist folder — a copy of dist/index.html
  3. Done. The host finds the file, serves it, and React Router takes over client-side.

Installation

npm install -D @kingironman2011/vite-pages
# or
pnpm add -D @kingironman2011/vite-pages
# or
yarn add -D @kingironman2011/vite-pages

Usage

// vite.config.ts
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { vitePages } from '@kingironman2011/vite-pages'

export default defineConfig({
  plugins: [
    react(),
    vitePages(),          // ← drop it in, zero config needed
  ],
})

That's it. Run vite build and every detected route gets its own index.html.


Options

vitePages({
  /**
   * Source directory to scan for route definitions.
   * @default 'src'
   */
  srcDir: 'src',

  /**
   * File extensions to include in the scan.
   * @default ['.tsx', '.ts', '.jsx', '.js']
   */
  extensions: ['.tsx', '.ts', '.jsx', '.js'],

  /**
   * Routes to always generate HTML for, regardless of auto-detection.
   * Useful for routes defined in config files outside the src folder.
   */
  additionalRoutes: ['/404', '/maintenance'],

  /**
   * Turn off automatic scanning entirely.
   * Only additionalRoutes will be used.
   * @default false
   */
  disableAutoScan: false,

  /**
   * Log detected routes and generated files to the console.
   * @default false
   */
  verbose: true,
})

Route detection

The plugin scans every .tsx/.ts/.jsx/.js file in your srcDir and extracts paths from:

| Pattern | Example | |---|---| | JSX attribute | <Route path="/about" …/> | | Object literal | { path: '/dashboard', element: … } |

What is intentionally skipped:

  • Dynamic segments: /user/:id, /post/:slug
  • Wildcard routes: *, /404/*
  • Template literals (not statically knowable)
  • The root / (already dist/index.html)

For routes with dynamic segments use additionalRoutes to manually list the static shells you want, e.g. /user.


GitHub Pages quick setup

  1. Add the plugin (see above)
  2. Set base in vite.config.ts to your repo name:
    base: '/my-repo-name/',
  3. Build and deploy the dist folder
  4. ✅ Refresh anywhere — no more 404s

Vite compatibility

| Vite version | Supported | |---|---| | 7.x | ✅ | | 8.x | ✅ |


License

MIT © KingIronMan2011