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

vite-on-github

v1.0.0

Published

One command to prepare any Vite project for GitHub Pages — auto config, base paths, CI, and router setup

Readme

vite-on-github

vite-on-github banner

npm version license

One command to prepare any Vite project for GitHub Pages — auto config, base paths, CI, and router setup.

No more fighting with base paths, broken assets, or manual GitHub Actions YAML.

Live demo: foisalislambd.github.io/vite-on-github (built from /demo)


The Problem

Deploying a Vite app to GitHub Pages usually means:

  • Setting the correct base URL (/repo-name/ vs /)
  • Fixing broken asset paths when the app lives in a subfolder
  • Configuring React Router / Vue Router basename
  • Writing a GitHub Actions workflow from scratch
  • Adding SPA fallback (404.html) for client-side routing

That's a lot of steps — and easy to get wrong.

The Solution

Run one command inside your Vite project:

npx vite-on-github

It automatically:

  1. Installs vite-basepath — relative asset paths that work in any subfolder
  2. Patches your vite.config.ts / vite.config.js to add the plugin
  3. Updates React Router / Vue Router with getBase() when detected
  4. Creates .github/workflows/deploy.yml for GitHub Pages
  5. Adds SPA 404.html fallback in the CI build step

Your app works at:

  • https://username.github.io/ (user site)
  • https://username.github.io/my-repo/ (project site)
  • Any nested path — no config changes needed

Quick Start

# Inside your Vite project folder
npx vite-on-github

Follow the prompts, then:

  1. Push to GitHub
  2. Go to Settings → Pages → Build and deployment
  3. Set Source to GitHub Actions
  4. Done — your site deploys on every push to main / master

CLI Reference

vite-on-github [command] [options]

Commands:
  init          Set up everything (default)
  help          Show help

Options:
  -y, --yes           Skip prompts
  --skip-install      Don't install vite-basepath
  --skip-vite-config  Don't patch vite.config
  --skip-router       Don't patch router files
  --skip-ci           Don't create workflow
  --node <version>    Node version for CI (default: 22)
  --out-dir <dir>     Build output (default: dist)

Examples

# Interactive setup
npx vite-on-github

# Non-interactive (CI / scripts)
npx vite-on-github init -y

# Custom Node version and output dir
npx vite-on-github init --node 20 --out-dir dist

What Gets Changed

| File | Change | |------|--------| | package.json | Adds vite-basepath dev dependency | | vite.config.* | Adds viteBasepath() plugin | | src/main.* or router | Adds getBase() for React/Vue Router | | .github/workflows/deploy.yml | GitHub Pages deploy workflow |

Existing config is patched, not replaced. Safe to run again — skips what's already done.


Programmatic API

Use in scripts or other tools:

import { init } from 'vite-on-github';

const result = await init({
  cwd: '/path/to/vite-project',
  yes: true,
});

console.log(result.pagesUrl); // https://user.github.io/repo/

How Base Paths Work

This package uses vite-basepath under the hood:

  • Build-time: sets Vite base to ./ (relative paths)
  • Runtime: detects the real deploy path automatically
  • Routers: getBase() returns the correct basename / history base

Same build works everywhere — root, subfolder, or nested path.


Demo site

The /demo folder is a full documentation site (same design as vite-basepath) adapted for vite-on-github. It deploys to GitHub Pages via .github/workflows/deploy-demo.yml.

cd demo
npm install
npm run dev      # local preview
npm run build    # production build + 404.html for Pages

After pushing to GitHub, enable Settings → Pages → GitHub Actions as the source.


Requirements

  • Node.js 18+
  • A Vite project (vite in package.json)
  • Git repository with GitHub remote (optional — for URL preview)

License

MIT