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

@ovineko/spa-guard-vite

v0.0.2-alpha-1

Published

Vite plugin and inline scripts for spa-guard

Readme

@ovineko/spa-guard-vite

npm license

Vite plugin for spa-guard — injects the runtime inline script and loading spinner into your SPA's HTML at build time.

Install

npm install @ovineko/spa-guard-vite @ovineko/spa-guard
npm install --save-dev vite

Usage

Add the plugin to your vite.config.ts:

import { spaGuardVitePlugin } from "@ovineko/spa-guard-vite";
import { defineConfig } from "vite";

export default defineConfig({
  plugins: [spaGuardVitePlugin()],
});

With options:

export default defineConfig({
  plugins: [
    spaGuardVitePlugin({
      version: "1.0.0",
      reloadDelays: [1000, 3000, 10000],
      html: { spinner: { background: "#f5f5f5" } },
    }),
  ],
});

Disable the spinner:

spaGuardVitePlugin({ html: { spinner: { disabled: true } } });

Enable trace mode (logs extra debug info at runtime):

spaGuardVitePlugin({ trace: true });

Use external script mode to write a content-hashed .js file instead of inlining the script:

spaGuardVitePlugin({
  mode: "external",
  externalScriptDir: "dist/assets",
  publicPath: "/assets",
});
// Injects <script src="/assets/spa-guard.abc12345.js"> into the HTML

Options

VitePluginOptions extends the core Options type and adds:

| Option | Type | Default | Description | | ------------------------- | ------------------------ | ------------ | -------------------------------------------------------- | | mode | 'inline' \| 'external' | 'inline' | Inject script inline or write an external file | | externalScriptDir | string | — | Output directory for external mode (e.g., dist/assets) | | publicPath | string | '/' | Public path prefix for the generated script URL | | version | string | auto UUID | Version string for cache busting | | reloadDelays | number[] | — | Retry delay sequence in ms | | useRetryId | boolean | — | Append retry ID to chunk URLs | | html.spinner.disabled | boolean | false | Disable loading spinner injection | | html.spinner.content | string | built-in SVG | Custom spinner HTML content | | html.spinner.background | string | "#fff" | Spinner overlay background color | | html.fallback.content | string | — | Fallback HTML shown on error (auto-minified) | | trace | boolean | false | Use trace build with debug logging |

What the plugin injects

In inline mode (default):

  • A <script> in <head> (prepended) containing the full spa-guard runtime inline

In external mode (mode: 'external'):

  • A <script src="..."> in <head> (prepended) referencing the content-hashed file
  • The content-hashed .js file is written to externalScriptDir (or Vite's build.outDir) during the bundle step

In both modes:

  • A spinner <div> in <body> (prepended) that hides until your app loads
  • A <script> to set overflow: hidden while loading
  • A <style> for the spinner background CSS variable (only when background differs from #fff)

Related packages

License

MIT