Sveltekit Svg screenshot

Sveltekit Svg

Author Avatar Theme by Poppa
Updated: 26 Nov 2025
280 Stars

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

Categories

Overview:

The SvelteKit SVG Plugin allows users to import SVG files as Svelte components, inline SVG code, or URLs. This plugin can be used in any Svelte project using Vite. The installation process involves adding the plugin as a dev dependency using either Yarn or npm. The plugin provides various options for importing SVGs, such as importing as a Svelte component, file path, or data URL. It also supports different SVGO options for optimizing SVGs. There are some recommendations provided for using the plugin with Jest and TypeScript.

Features:

  • Import SVG files as Svelte components, inline SVG code, or URLs
  • Works with any Svelte project using Vite
  • Multiple SVG transformers can be applied based on paths
  • Supports different SVGO options for optimizing SVGs
  • Provides options to import SVGs as file paths or data URLs
  • Allows passing attributes to the imported SVG components
  • Recommendations for using the plugin with Jest and TypeScript

Installation:

To install the SvelteKit SVG Plugin, follow these steps:

  1. Open your project’s terminal.
  2. Run the following command to install the plugin using Yarn:
    yarn add --dev @poppanator/sveltekit-svg
    
    or using npm:
    npm install -D @poppanator/sveltekit-svg
    

Summary:

The SvelteKit SVG Plugin is a useful tool for Svelte developers working with SVG files. It allows for seamless importing of SVGs as Svelte components, inline code, or URLs in a Svelte project using Vite. The plugin provides options for optimizing SVGs using SVGO and supports importing SVGs as file paths or data URLs. However, there are some recommendations to follow when using the plugin with Jest and TypeScript to avoid conflicts and errors. Overall, the SvelteKit SVG Plugin simplifies the process of working with SVGs in Svelte applications.