Skip to content
PluginStats

vite-plugin-magical-svg weekly downloads statistics

npm · Vite plugins

An all-in-one Vite plugin that magically makes working with SVGs and bundling them a breeze

View on npm Fresh · Oct 18, 2026

vite-plugin-magical-svg has 5,859 recorded weekly downloads on npm, a decrease of 64.1% over the past 30 days, ranking #1094 of 2,322 tracked listings.

Weekly downloads
5,859
Official API · Oct 18, 2026
7-day growth
-60.3%
-8.9K weekly downloads
30-day growth
-64.1%
-10.5K weekly downloads
90-day growth
-55.6%
-7.3K weekly downloads
Rank
#1094
Among tracked npm listings

About vite-plugin-magical-svg

Magical SVG 🪄

License npm Build

GitHub Sponsors Weekly downloads Monthly downloads

An all-in-one Vite plugin that magically makes working with SVGs and bundling them a breeze.

This plugin lets you import SVG files as components, with advanced pre-processing of assets referenced within SVGs, without the inefficient approach used by other tools. SVGs will be bundled in a spritesheet that is fast and lightweight for the browser. See the backstory for more details.

[!TIP] Can mostly be used as a drop-in replacement of SVGR and similar tools.

Backstory

Inspired by a tweet from Preact's creator Jason Miller, I've been looking at plugins that would let me work with SVGs, as I myself did the error of embedding SVGs as React components. Shame!

What I wanted was a plugin that would let me import SVGs, and make a sprite of symbols and give me the identifier I can use in <use href='???'/>. And I couldn't find any decent plugin that makes working with them easy. They all had a problem that made using them a pain, or outright impractical. Here's a list of the problems I encountered:

  • References in SVG files are never processed. <image href='...'/> would never get processed and the referenced asset is ignored.
  • The generated sprite include ALL icons, even unused ones. Just picking the right icons from a pack isn't an option.
  • There are no options to output to a separate file and reference it. Inlining is apparently the only way.
  • Selectively tell to not process a specific SVG isn't possible (e.g.: A logo, or SVGs that break when encapsulated in a symbol).
  • You can't make different sprites, it's only all-in-one.

So I decided to make my own tool to solve all these problems. Introducing: the Magical SVG plugin. 🪄

Install

pnpm i vite-plugin-magical-svg
yarn add vite-plugin-magical-svg
npm i vite-plugin-magical-svg

Usage

[!NOTE] During development, to keep HMR fast and efficient, the sprite is not produced and instead the plugin falls back to embedding the symbol inside the generated component.

Vite plugin setup
import { defineConfig } from 'vite'
import magicalSvg from 'vite-plugin-magical-svg'

export default defineConfig({
	plugins: [
		magicalSvg({
			// By default, the output will be a dom element (the <svg> you can use inside the webpage).
			// You can also change the output to react (or any supported target) to get a component you can use.
			target: 'preact',

			// By default, the svgs are optimized with svgo. You can disable this by setting this to false.
			svgo: false,

			// By default, width and height set on SVGs are not preserved.
			// Set to true to preserve `width` and `height` on the generated SVG.
			preserveWidthHeight: false,

			// *Experimental* - set the width and height on generated SVGs.
			// If used with `preserveWidthHeight`, will only apply to SVGs without a width/height.
			setWidthHeight: { width: '24', height: '24' },

			// *Experimental* - replace all instances of `fill="..."` and `stroke="..."`.
			// Set to `true` for 'currentColor`, or use a text value to set it to this value.
			// When enabled, use query param ?skip-recolor to not alter colors.
			// Disabled by default.
			setFillStrokeColor: true,

			// *Experimental* - if a SVG comes with `width` and `height` set but no `viewBox`,
			// assume the viewbox is `0 0 {width} {height}` and add it to the SVG.
			// Disabled by default.
			restoreMissingViewBox: true,
		})
	]
})
Targets
  • dom (default): exports a DOM element1. Uses document.createElementNS under the hood.
  • dom-fn: exports a function you can call (takes no arguments) and returns a DOM element. Uses document.createElementNS under the hood.
  • dom-template: similar to dom-fn, but leverages document.createElement('template').innerHTML. More compact than dom-fn, but relies on innerHTML.
  • react19: exports a functional React component (classic runtime)
  • react19-jsx: exports a functional React component (automatic runtime)
  • react: exports a functional React component (classic runtime; wrapped in forwardRef)
  • react-jsx: exports a functional React component (automatic runtime; wrapped in forwardRef)
  • preact: exports a functional Preact component (classic runtime; wrapped in forwardRef)
  • preact-jsx: exports a functional Preact component (automatic runtime; wrapped in forwardRef)
  • vue: exports a Vue component (as if it was a .vue file)
  • vue-vapor: exports a Vue Vapor2 component (as if it was a .vue file)
  • solid: exports a Solid component
  • ember: exports an Ember component

Footnotes

  1. This target was supposed to behave as dom-fn actually, but I messed up the implementation. To avoid breaking changes, dom-fn has been introduced with a more sensible behaviour. See [#26].… ↩

  2. Vue's high-performance subset introduced in Vue 3.6. ↩

Description from the npm listing.

  • vite-plugin
  • spritesheet
  • sprite
  • svgr
  • svg

README badge

Show your rank in a README or on your website. The badge updates automatically.

Charts

Images: 30d · 1y · all time · 1600×900 dark

Adoption over time

vite-plugin-magical-svg weekly downloads on npm, last 90 days: 5,859 weekly downloads as of Oct 18, 2026, -55.6% over 90 days.vite-plugin-magical-svgWeekly downloads on npm · Last 90 days5,859downloads / week-55.6% over 90 days05K10K15K20KJul 20Aug 4Aug 19Sep 3Sep 18Oct 3Oct 18downloads / weekobservedarchived (Internet Archive)no observationsJul 22, 2026 – Oct 18, 2026 · 89 observations · Updated Oc…pluginstats.com
vite-plugin-magical-svg weekly downloads on npm, last 90 days: 5,859 weekly downloads as of Oct 18, 2026, -55.6% over 90 days.

7/30/90-day growth

vite-plugin-magical-svg weekly downloads growth on npm: -60.3% over 7 days, -64.1% over 30 days, -55.6% over 90 days.vite-plugin-magical-svgWeekly downloads growth on npm5,859downloads / week now7-day growth-8,899 weekly downloads-60.3%30-day growth-10,452 weekly downloads-64.1%90-day growth-7,324 weekly downloads-55.6%Growth vs. nearest observation to each baseline date · Updated Oct 18, 2026pluginstats.com
vite-plugin-magical-svg weekly downloads growth on npm: -60.3% over 7 days, -64.1% over 30 days, -55.6% over 90 days.

Ranking history

vite-plugin-magical-svg npm ranking history: currently #1094 (by weekly downloads).vite-plugin-magical-svgnpm ranking · by weekly downloads · Last 90 days#1094current rank#400#500#600#700#800#900#1000#1100Jul 22Aug 6Aug 21Sep 5Sep 20Oct 5Oct 20rankOct 17, 2026 – Oct 20, 2026 · 4 observations · Updated Oct 18, 2026pluginstats.com
vite-plugin-magical-svg npm ranking history: currently #1094 (by weekly downloads).

Listing placement

All npm2,320 listings · 116 pages · 1,162 shown · page 55, #16 (overall #1,096)
All npm: every listing in weekly downloads order

Listing placement

Vite plugins253 listings · 13 pages · page 10, #18 (overall #198)
Vite plugins: every listing in weekly downloads order

Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.

Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.

Recent observations

Full history (543)
Recent weekly downloads observations for vite-plugin-magical-svg
Date (UTC)Weekly downloadsChange vs. previous
5,859+68
5,791-364
6,155+83
6,072-4K
10,050-4.5K
14,5980
14,598-160
14,758+161
14,597-125
14,722-127
14,849+214
14,635+1.2K
13,421-4.6K
18,060—

Similar npm Vite plugins plugins

All 20 vite-plugin-magical-svg alternatives

Data source

Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.

Listing: https://www.npmjs.com/package/vite-plugin-magical-svg. First seen Oct 16, 2026; last successful collection Oct 20, 2026. See the methodology.