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

svg-sprite-watcher

v0.1.1

Published

TypeScript-first SVG sprite generator and watcher with framework integrations

Readme

svg-sprite-watcher

TypeScript-first SVG sprite generator with watch mode, type generation, and framework integrations.

Features

  • Generate a single SVG sprite from one or more icon folders
  • Watch mode with auto-regeneration on icon changes
  • Auto-generate IconName TypeScript definitions from sprite symbols
  • React and Astro icon components
  • Vite and Astro integrations

Install

pnpm i -D svg-sprite-watcher

Quick start

pnpm i -D svg-sprite-watcher
pnpm svg-sprite-watcher init
pnpm svg-sprite-watcher
pnpm svg-sprite-watcher --watch

Config (sprite-config.ts)

import type { SpriteConfig } from "svg-sprite-watcher/types/config";

export default {
  input: "src/icons",
  output: "public/sprite.svg",
  spriteUrl: "/sprite.svg",
  generateTypes: true,
  typesOutput: "src/sprite.d.ts",
  ignore: ["**/*.test.svg"],
} satisfies SpriteConfig;

CLI options

svg-sprite-watcher [options]

Options:
  -w, --watch          Watch and regenerate on file changes
  -c, --config <path>  Use custom config file
  -r, --run <command>  Run another command concurrently
  --no-types           Disable type generation

Commands:
  init                 Create sprite-config.ts interactively

API

import { runCoreGenerator } from "svg-sprite-watcher";

Also exported:

  • iconNames
  • isValidIcon
  • svg-sprite-watcher/types/config

React component

import { Icon } from "svg-sprite-watcher/components/react";

<Icon name="home" size={20} />

Astro component

---
import Icon from "svg-sprite-watcher/components/astro";
---

<Icon name="home" size={20} />

Vite integration

import { defineConfig } from "vite";
import svgSpritePlugin from "svg-sprite-watcher/plugins/vite";

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

Astro integration

import { defineConfig } from "astro/config";
import svgSpritePlugin from "svg-sprite-watcher/plugins/astro";

export default defineConfig({
  integrations: [svgSpritePlugin()],
});

Framework-agnostic setup (Next.js, Remix, custom SSR, etc.)

If your framework does not use a dedicated plugin, run the sprite CLI in parallel with your dev server and once before build.

  1. Add sprite-config.ts in your app root.
  2. Output sprite to a public path (for example public/sprite.svg).
  3. Run watch mode in dev, and one-shot generation in build.

Example scripts (Next.js):

{
  "scripts": {
    "sprite:watch": "svg-sprite-watcher --watch",
    "sprite:build": "svg-sprite-watcher",
    "dev": "concurrently \"pnpm sprite:watch\" \"next dev\"",
    "build": "pnpm sprite:build && next build"
  }
}

Example usage in React/Next components:

import { Icon } from "svg-sprite-watcher/components/react";

<Icon name="home" size={20} spriteUrl="/sprite.svg" />

Internal flow

loadConfig()
   -> scanIcons()
   -> generateSprite()
   -> generateTypes() [optional]

watch mode:
chokidar events -> debounce -> rerun pipeline

Behavior notes

  • Duplicate icon filenames are logged; last one found wins.
  • If spriteUrl is not provided, it is inferred from output basename.
  • Type generation reads <symbol id="..."> from the generated sprite.