v0.6.0 on npm · MIT · Node ^22.20 || >=24.11

Your icons.
Right colors.

Multicolor icons going black? Gradients blank in SSR? Turbopack plugin failing?

svgworm decides per icon, with no config: mono icons follow currentColor, multicolor icons keep their colors, and gradients and masks keep working. It renders in Server Components from one sprite, plus a stack file for the gradient and mask icons, with typed names, no plugin and zero client JS.

Install command for

pnpm add -D svgworm && pnpm add @svgworm/react && pnpm svgworm init

pnpm add -D svgworm && pnpm add @svgworm/react && pnpm svgworm init

pnpm add -D svgworm && pnpm svgworm init

pnpm add -D svgworm && pnpm svgworm init

pnpm add -D svgworm && pnpm svgworm init

Only using lucide or another icon set? Its React package is fine. svgworm is for the icons you own.

Or paste this into your coding agent

Or paste this into your coding agent

Set up svgworm in this project for my SVG icons. Read https://svgworm.com/llms.txt, detect the framework (Next.js, Vite + React, Astro, Vue or Svelte), follow the matching guide linked there, and run the build to check it works.
~/my-app
$ pnpm svgworm
svgworm: reading 25 SVG file(s)
write public/icons/icons.ce28be92.svg (11.5 KiB)
write public/icons/icons.stack.0222d2e4.svg (1.5 KiB)
write svgworm/icons.js (4.2 KiB)
write svgworm/icons.d.ts (1.0 KiB)
write svgworm/manifest.json (4.1 KiB)
svgworm: build done
  icons     25 (18 mono, 7 multicolor)
  delivery  use 23, img 1, mask 1
  source    15.7 KiB
  output    13.0 KiB (sprite 11.5 KiB, stack 1.5 KiB)
  savings   2.8 KiB (17.5%)

$ pnpm tsc
app/page.tsx(4,27): error TS2820: Type '"termnial"' is not
assignable to type 'IconName'. Did you mean '"terminal"'?
0 BJavaScript for icons
2 filesfor all 25 icons
13.0 KiBsprite and stack
1 yearimmutable browser cache

File count and size are read from this page's build, and the cache time from its _headers. The icon component ships no script.

This page is the demo

One folder, every icon right.

A sprite tool has to decide, per icon, whether to turn its fills intocurrentColor. Do it for the whole folder and logos turn into black blobs; never do it and mono icons ignore dark mode. svgworm decides per icon: on 31,390 icons it agreed with the rendering 99.98% of the time, and it recolored 0 multicolor icons. How it decides.

simulated

Recolor the whole folder

live output

svgworm, per icon

Both sides are the same icons from this page's build. The left adds a CSS brightness(0) filter to imitatefill="currentColor" on every path, under black text.

Same folder, decided per icon. Pick a text color. Mono icons follow it, whether they render through use or a CSS mask. Multicolor icons keep their own colors. No JavaScript, only CSS color.

Text color
  • use
  • mask
  • use
  • img

/icons/icons.ce28be92.svg and /icons/icons.stack.0222d2e4.svg, rendered by the generated Icon.astro at build time and served withCache-Control: immutable. Open your network panel: two icon files and no JavaScript to render them.

Multicolor 7 icons, colors kept

  • emoji/carrot
  • emoji/mushroom
  • emoji/rock
  • emoji/seedling
  • emoji/snail
  • emoji/worm
  • proof/agate

Mono 18 icons, follow currentColor

  • arrow-right
  • book-open
  • check
  • copy
  • file-code
  • folder-open
  • gauge
  • git-branch
  • layers
  • package
  • pause
  • play
  • proof/fossil
  • server
  • shield-check
  • star
  • terminal
  • zap

One icon, end to end

Follow agate.svg from file to render.

The hardest icon on this site: gradients and a clip path, which WebKit drops from an external <use>. Steps 1 to 3 are read from its committed files when the page was built, and step 4 is the markup this page rendered. Nothing is pasted in.

  1. you write

    Your SVG file

    Drop it in icons/ as exported, comments and all.

    icons/proof/agate.svg, 23 lines
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
      <!-- Agate pebble, drawn for this site. Gradients and a clip path. -->
      <defs>
        <radialGradient id="rind" cx="0.38" cy="0.32" r="0.8">
          <stop offset="0" stop-color="#de8f8a"/>
          <stop offset="0.6" stop-color="#b85c5e"/>
          <stop offset="1" stop-color="#6e2a32"/>
        </radialGradient>
        <linearGradient id="band" x1="0" y1="0" x2="1" y2="1">
          <stop offset="0" stop-color="#fbf7f0"/>
          <stop offset="1" stop-color="#f0c27b"/>
        </linearGradient>
        <clipPath id="stone">
          <path d="M16 3.5c7 0 12.5 4.6 12.5 11.6 0 8-5.4 13.4-13 13.4-7.2 0-12-4.9-12-12.1C3.500 8.800 9 3.500 16 3.500z"/>
        </clipPath>
      </defs>
      <path fill="url(#rind)" d="M16 3.5c7 0 12.5 4.6 12.5 11.6 0 8-5.4 13.4-13 13.4-7.2 0-12-4.9-12-12.1C3.500 8.800 9 3.500 16 3.500z"/>
      <g clip-path="url(#stone)" fill="none" stroke="url(#band)" stroke-width="1.8">
        <ellipse cx="19" cy="18" rx="4" ry="2.8"/>
        <ellipse cx="19" cy="18" rx="7.5" ry="5.600"/>
        <ellipse cx="19" cy="18" rx="11.500" ry="9"/>
      </g>
    </svg>
  2. svgworm generates

    An entry in the stack file

    Its url(#…) references keep it out of the sprite, so it goes to public/icons/icons.stack.0222d2e4.svg, optimized.

    <svg id="i-proof--agate" viewBox="0 0 32 32"><defs><radialGradient id="i-proof--agate_1" cx=".38" cy=".32" r=".8"><stop offset="0" stop-color="#de8f8a"/><stop offset=".6" stop-color="#b85c5e"/><stop offset="1" stop-color="#6e2a32"/></radialGradient><linearGradient id="i-proof--agate_2" x1="0" x2="1" y1="0" y2="1"><stop offset="0" stop-color="#fbf7f0"/><stop offset="1" stop-color="#f0c27b"/></linearGradient><clipPath id="i-proof--agate_3"><path d="M16 3.5c7 0 12.5 4.6 12.5 11.6 0 8-5.4 13.4-13 13.4-7.2 0-12-4.9-12-12.1C3.5 8.8 9 3.5 16 3.5"/></clipPath></defs><path fill="url(#i-proof--agate_1)" d="M16 3.5c7 0 12.5 4.6 12.5 11.6 0 8-5.4 13.4-13 13.4-7.2 0-12-4.9-12-12.1C3.5 8.8 9 3.5 16 3.5"/><g fill="none" stroke="url(#i-proof--agate_2)" stroke-width="1.8" clip-path="url(#i-proof--agate_3)"><ellipse cx="19" cy="18" rx="4" ry="2.8"/><ellipse cx="19" cy="18" rx="7.5" ry="5.6"/><ellipse cx="19" cy="18" rx="11.5" ry="9"/></g></svg>
  3. svgworm generates

    Its manifest entry

    The id, size, color and delivery the component reads.

    "proof/agate": {
      "sprite": "icons",
      "id": "i-proof--agate",
      "viewBox": "0 0 32 32",
      "color": "multicolor",
      "delivery": "img"
    }
  4. you write

    One line in your page

    It renders as an <img>:

    <Icon name="proof/agate" />
    // <img alt src="/icons/icons.stack.0222d2e4.svg#i-proof--agate" style="width:1em;height:1em;">

Why svgworm

Everything else stays out of your bundle.

SVGR turns every icon into JavaScript, svgworm ships a cached file and a name. How it compares with SVGR and @neodx/svg.

Rendered on the server

Most icons are a tiny <use href> into one hashed sprite. The browser fetches the sprite once and keeps it.

Type-safe names

The generated types list every icon. A typo fails tsc, not production.

<Icon name="termnial" />
  • Autocomplete in your editor
  • Checked with TypeScript 6 and 7
  • Clear errors for collisions
  • Renamed icons fail the type check

Right colors, per icon

Mono icons follow currentColor, multicolor icons keep their colors. Gradients, masks and filters render in Chromium, Firefox and WebKit. See the render matrix. That is Playwright's WebKit, not Safari.

Plain files, no plugin

A CLI that writes static files. They are byte-identical on Linux, macOS and Windows. Turbopack, webpack and Vite need no plugin. svgworm check fails CI when the output is stale. CI compares them on every PR.

Get started in Next.js

Three steps, no bundler config.

  1. Install and set up

    init writes the config, the predev/prebuild scripts and the component. Then it builds once, so the app runs before you add an icon.

    pnpm add -D svgworm
    pnpm add @svgworm/react
    pnpm svgworm init
  2. Drop SVGs in icons/ and build

    Each run writes a hashed sprite to public/icons/ and a typed manifest to svgworm/. predev and prebuild run it for you.

    icons/
    ├── home.svg
    ├── search.svg
    └── brand/logo.svg
    
    pnpm svgworm
  3. Render in a Server Component

    Decorative by default. Pass title orlabel for an accessible name.

    <Icon name="home" />
    <Icon name="home" title="Home" />

Caching, basePath and manual setup are in the Next.js guide. A complete app lives in examples/next-app-router.

Built for AI agents too

Your agent can set it up.

Everything works without a prompt: flags,--json, stable exit codes, a JSON Schema for the config, and llms.txt. The agent skills install svgworm in a Next.js or an Astro app. They also explain each diagnostic code with its fix.

$ npx skills add jmlweb/svgworm --skill svgworm-nextjs
$ npx skills add jmlweb/svgworm --skill svgworm-astro

Moving from SVGR, or mixing an icon set with your own SVGs?

Move them into svgworm. Pick where you come from and paste the prompt into your agent.

Migrate from
Migrate this project's SVG icons from SVGR to svgworm. Read https://svgworm.com/llms.txt first and set svgworm up with the guide for this project's framework, with the folder that holds the SVG files SVGR imports as the svgworm source. Replace every SVGR icon import and its component with the svgworm icon component, keeping the same icons. Remove the SVGR loader rules from the bundler config and @svgr/webpack from package.json once nothing uses them. Run the build and the type check to confirm every icon name resolves.
Migrate this project from lucide-react to svgworm. Read https://svgworm.com/llms.txt first and set svgworm up with the guide for this project's framework. Then copy the SVG source of each lucide-react icon the code uses into the icons folder, replace every lucide-react import with the svgworm icon component, and remove lucide-react from package.json once nothing imports it. Run the build and the type check to confirm every icon name still resolves.
Migrate this project from react-icons to svgworm. Read https://svgworm.com/llms.txt first and set svgworm up with the guide for this project's framework. Then copy the SVG source of each react-icons icon the code uses into the icons folder, replace every react-icons import with the svgworm icon component, and remove react-icons from package.json once nothing imports it. Run the build and the type check to confirm every icon name still resolves.

Pick your framework

One guide per stack.

Astro

A dependency-free Icon.astro written by init.

Point it at your icon folder.

One init, Next.js, Vite, Astro, Vue or Svelte, and your icons ship as static, cached files.

pnpm add -D svgworm && pnpm add @svgworm/react && pnpm svgworm init

pnpm add -D svgworm && pnpm add @svgworm/react && pnpm svgworm init

pnpm add -D svgworm && pnpm svgworm init

pnpm add -D svgworm && pnpm svgworm init

pnpm add -D svgworm && pnpm svgworm init