whatisgithub

What is svgr?

gregberge/svgr — explained in plain English

Analysis updated 2026-06-24

11,029TypeScriptAudience · developerComplexity · 2/5LicenseSetup · easy

In one sentence

SVGR converts SVG image files into React components automatically, so you can use icons and illustrations as interactive, prop-accepting pieces of your UI without rewriting markup by hand.

Mindmap

mindmap
  root((svgr))
    What it does
      SVG to React convert
      Prop-ready output
      SVG optimization
    Usage modes
      CLI tool
      Webpack plugin
      Node.js library
    Use cases
      Icon components
      Illustration reuse
      Build automation
    Audience
      React developers
      Frontend designers
      Build engineers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Convert a folder of SVG icons into reusable React components you can resize and recolor with props

USE CASE 2

Use the SVGR webpack plugin to automatically convert imported SVG files during your JavaScript build

USE CASE 3

Run SVGR from the terminal as a CLI tool to transform individual SVG files into React components

USE CASE 4

Use the online playground at react-svgr.com to preview the React component output without installing anything

What is it built with?

TypeScriptNode.jswebpack

How does it compare?

gregberge/svgrbytebot-ai/bytebotgristlabs/grist-core
Stars11,02911,01311,045
LanguageTypeScriptTypeScriptTypeScript
Setup difficultyeasymoderatemoderate
Complexity2/54/54/5
Audiencedeveloperdevelopergeneral

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min
Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

So what is it?

SVGR is a tool that converts SVG image files into React components. SVG is a format for vector graphics (logos, icons, illustrations that stay sharp at any size), and React is a popular JavaScript library for building user interfaces. Normally, using an SVG inside a React app requires some manual work to make it fit the component model. SVGR automates that conversion entirely. You point SVGR at an SVG file and it outputs a clean React component you can drop straight into your code. That component accepts the same props as any React element, so you can resize it, change its color, or wire it up to click handlers just like any other piece of your UI. The tool also runs the SVG through an optimizer first, stripping out unnecessary metadata and attributes that design tools like Sketch tend to leave behind. SVGR can be used in several ways: as a command-line tool you run directly in a terminal, as a plugin for webpack (a common build tool for JavaScript projects), or as a Node.js library you call from your own scripts. There is also an online playground at react-svgr.com where you can paste an SVG and immediately see the React component output, without installing anything. The project is MIT licensed and free to use. It was developed by Greg Berge and gained wider adoption after being included in create-react-app, a standard starter kit for React projects. It is supported through sponsorships on GitHub and OpenCollective. If you are building a React application and want to include icons or illustrations as interactive components rather than static image tags, this library handles the conversion so you do not have to rewrite SVG markup by hand.

Copy-paste prompts

Prompt 1
Show me how to use the SVGR CLI to batch-convert a folder of SVG icons into React components
Prompt 2
How do I configure the SVGR webpack plugin so all SVG imports in a project automatically become React components?
Prompt 3
How do I make an SVGR-generated React component accept a size and fill color as props?
Prompt 4
Show me how to use SVGR as a Node.js library in a build script to convert SVGs programmatically
Prompt 5
What cleanup does SVGR apply to SVG files exported from Sketch or Figma before converting them?

Frequently asked questions

What is svgr?

SVGR converts SVG image files into React components automatically, so you can use icons and illustrations as interactive, prop-accepting pieces of your UI without rewriting markup by hand.

What language is svgr written in?

Mainly TypeScript. The stack also includes TypeScript, Node.js, webpack.

What license does svgr use?

Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

How hard is svgr to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is svgr for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.