Skip to content
PluginStats

@poppanator/sveltekit-svg weekly downloads statistics

By poppanator · npm · Vite plugins

Import SVG files as Svelte components

View on npm Stale · Oct 18, 2026

@poppanator/sveltekit-svg has 16,221 recorded weekly downloads on npm, a decrease of 41.7% over the past 30 days.

Weekly downloads
16,221
Official API · Oct 18, 2026
7-day growth
-39.1%
-10.4K weekly downloads
30-day growth
-41.7%
-11.6K weekly downloads
90-day growth
-54.6%
-19.5K weekly downloads
Rank
—
Among tracked npm listings

About @poppanator/sveltekit-svg

SvelteKit SVG Plugin

This plugin makes it possible to import SVG files as Svelte components, inline SVG code or urls.

NOTE! For Svelte 4 projects, use version 4 of this plugin

NOTE! This plugin isn't just for SvelteKit, but works for any Svelte project using Vite

Install

  • yarn add --dev @poppanator/sveltekit-svg
  • npm install -D @poppanator/sveltekit-svg

Usage

In your vite.config.js

import { sveltekit } from '@sveltejs/kit/vite'
import svg from '@poppanator/sveltekit-svg'

/** @type {import('vite').UserConfig} */
const config = {
  plugins: [
    sveltekit(),
    svg(options), // Options are optional
  ],
}

export default config

You can also pass multiple svg transformers based on paths if you want to apply different SVGO options for different SVGs

const config = {
  plugins: [
    sveltekit(),
    svg({
      includePaths: ['./src/lib/icons/', './src/assets/icons/'],
      svgoOptions: {
        multipass: true,
        plugins: [
          {
            name: 'preset-default',
          },
          { name: 'removeAttrs', params: { attrs: '(fill|stroke)' } },
        ],
      },
    }),
    svg({
      includePaths: ['./src/lib/graphics/'],
      svgoOptions: {
        multipass: true,
        plugins: ['preset-default'],
      },
    }),
  ],
}

Svelte usage

Import as a Svelte component:

NOTE! It's recommended that you use the ?component query string if you use the suggested type definition below. The reason is that Vite ships a type definition for *.svg which states that import Comp from './file.svg returns a string.

So providing a default type definition for *.svg is in most cases causing a conflict which will lead to TSC errors when treating such an import as a Svelte component.

So the best way to avoid errors, current and future, is to always use import Comp from './file.svg?component with the suggested type definition at the end of this file.

<script>
import Logo from "./logo.svg?component";
</script>

<Logo />

When used as a component you can also pass attributes to the SVG

<Logo width="200" />

Import as file path:

<script>
import logoUrl from "./logo.svg?url";
</script>

<img src={logoUrl} />

Import as data URL:

<script>
import logoDataUrl from "./logo.svg?dataurl";
</script>

<img src={logoDataUrl} />

In contrast to ?url this will apply SVGO optimization/transform before the the SVG is turned into a data URL

You can also pass the SVGO config option datauri as value to ?dataurl. This will, for instance, generate an URI encoded string

<script>
import logoDataUrl from "./logo.svg?dataurl=enc";
</script>

<img src={logoDataUrl} />

Import as code:

<script>
import logo from "./logo.svg?src";
</script>

{@html logo}

Options

interface Options {
  /**
   * Output type
   *
   * `dataurl` can also take the following options, which are verbatim SVGO
   * `datauri` options:
   *
   * - `?dataurl=base64` (default, same as `?dataurl`)
   * - `?dataurl=enc` URL encoded string
   * - `?dataurl=unenc` Plain SVG
   *
   * @default "component"
   */
  type?: 'src' | 'url' | 'component' | 'dataurl'
  /**
   * Verbatim [SVGO](https://github.com/svg/svgo) options
   *
   * If no options are given, the SVG will be optimized with the default SVGO
   * options.
   * If `false` SVGO will be bypassed altogether
   */
  svgoOptions?: Config | false
  /**
   * Paths to apply the SVG plugin on. This can be useful if you want to apply
   * different SVGO options/plugins on different SVGs.
   *
   * The paths are path prefixes and should be relative to your
   * `svelte.config.js` file.
   *
   * @example
   * ```
   * {
   *   includePaths: ['src/assets/icons/', 'src/images/icons/']
   * }
   * ```
   */
  includePaths?: string[]
  /**
   * Hook that lets you transform the svg to a raw Svelte component yourself,
   * before being passed to the Svelte compiler.
   *
   * @param rawSvg The raw SVG data as read from disk
   * @param splitSvg The SVG split into parts, e.g its attributes and
   *  its content
   * @returns This should return a complete Svelte component that can be passed
   *  to the Svelte compiler
   */
  preCompileHook?(rawSvg: string, splitSvg: SplitSvg): string
}

Typescript

For Typescript not to complain about file.svg?component et.al, add the following import statement to src/app.d.ts (or any .d.ts file somewhere in the path of your project where tsc can find it).

import '@poppanator/sveltekit-svg/dist/svg.d.ts'

NOTE! If you have module/moduleResolution set to NodeNext in your Typescript config, you MUST include .d.ts in the import of the SVG type definition.

Notes on using with Jest

I don't know if this still applies, but it's kept here for good measure

According to a report Jest will have trouble transforming .svg files when such is imported as a Svelte component.

The solution seems to be to add a module name mapper entry in the the jest.config.cjs file, like so:

module.exports = {
  // ... other config
  moduleNameMapper: {
    // ... other mappers
    '^.+\\.svg$': '<rootDir>/src/lib/EmptyIcon.svelte',
  },
}

where src/lib/EmptyIcon.svelte can contain just <svg />.

See the reported issue and solution

Description from the npm listing.

  • svelte-plugin
  • svelte
  • sveltekit-plugin
  • sveltekit
  • svg
  • svgo
  • vite-plugin
  • vite

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

@poppanator/sveltekit-svg weekly downloads on npm, last 90 days: 16,221 weekly downloads as of Oct 18, 2026, -54.6% over 90 days.@poppanator/sveltekit-svgWeekly downloads on npm · Last 90 days16,221downloads / week-54.6% over 90 days10K15K20K25K30K35K40KJul 20Aug 4Aug 19Sep 3Sep 18Oct 3Oct 18downloads / weekobservedarchived (Internet Archive)no observationsJul 25, 2026 – Oct 18, 2026 · 86 observations · Updated Oc…pluginstats.com
@poppanator/sveltekit-svg weekly downloads on npm, last 90 days: 16,221 weekly downloads as of Oct 18, 2026, -54.6% over 90 days.

7/30/90-day growth

@poppanator/sveltekit-svg weekly downloads growth on npm: -39.1% over 7 days, -41.7% over 30 days, -54.6% over 90 days.@poppanator/sveltekit-svgWeekly downloads growth on npm16,221downloads / week now7-day growth-10,402 weekly downloads-39.1%30-day growth-11,624 weekly downloads-41.7%90-day growth-19,521 weekly downloads-54.6%Growth vs. nearest observation to each baseline date · Updated Oct 18, 2026pluginstats.com
@poppanator/sveltekit-svg weekly downloads growth on npm: -39.1% over 7 days, -41.7% over 30 days, -54.6% over 90 days.

Ranking history

@poppanator/sveltekit-svg npm ranking history: currently #837 (by weekly downloads).@poppanator/sveltekit-svgnpm ranking · by weekly downloads · Last 90 days#837current rank#200#300#400#500#600#700#800#900Jul 23Aug 7Aug 22Sep 6Sep 21Oct 6Oct 21rankOct 17, 2026 – Oct 21, 2026 · 5 observations · Updated Oct 18, 2026pluginstats.com
@poppanator/sveltekit-svg npm ranking history: currently #837 (by weekly downloads).

Listing placement

All npm2,429 listings · 122 pages · 1,216 shown · page 43, #2 (overall #842)
All npm: every listing in weekly downloads order

Listing placement

Vite plugins258 listings · 13 pages · page 7, #17 (overall #137)
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 (544)
Recent weekly downloads observations for @poppanator/sveltekit-svg
Date (UTC)Weekly downloadsChange vs. previous
16,221+2.7K
13,561-2.1K
15,614+1.6K
14,012-6.2K
20,194-6.4K
26,5640
26,564-59
26,623-101
26,724+242
26,482-550
27,032-1K
28,050-146
28,196-5.9K
34,084—

Similar npm Vite plugins plugins

All 20 @poppanator/sveltekit-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/@poppanator/sveltekit-svg. First seen Oct 16, 2026; last successful collection Oct 23, 2026. See the methodology.