Gathering detailed insights and metrics for gatsby-plugin-svgr-svgo
Gathering detailed insights and metrics for gatsby-plugin-svgr-svgo
Gathering detailed insights and metrics for gatsby-plugin-svgr-svgo
Gathering detailed insights and metrics for gatsby-plugin-svgr-svgo
Gatsby plugin for SVG usage with react, svgo support
npm install gatsby-plugin-svgr-svgo
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
402,134
Last Day
57
Last Week
5,228
Last Month
19,642
Last Year
146,710
17 Stars
51 Commits
1 Forks
3 Watchers
15 Branches
9 Contributors
Updated on Jul 28, 2025
Latest Version
2.0.0
Package Id
gatsby-plugin-svgr-svgo@2.0.0
Unpacked Size
8.40 kB
Size
2.85 kB
File Count
5
NPM Version
6.14.6
Node Version
12.18.3
Cumulative downloads
Total Downloads
Last Day
78.1%
57
Compared to previous day
Last Week
25.3%
5,228
Compared to previous week
Last Month
-6.5%
19,642
Compared to previous month
Last Year
113.6%
146,710
Compared to previous year
2
2
Plugin allows you to use SVGs as react components, configure SVGO(SVG optimization) settings and declare rules for SVG url loader with or without optimization.
For Gatsby 3.0.0+ versions use
npm install gatsby-plugin-svgr-svgo @svgr/webpack --save
For Gatsby 2.3.0+ versions use
npm install gatsby-plugin-svgr-svgo@1.1.0 @svgr/webpack --save
For older versions
npm install gatsby-plugin-svgr-svgo@v1.0.12 @svgr/webpack --save
Add to your gatsby-config.js
1plugins: [`gatsby-plugin-svgr-svgo`];
By default there are two rules will be added:
cat.inline.svg
1import React from "react"; 2import CatInlineSvg from "../images/cat.inline.svg"; 3 4const IndexPage = () => ( 5 <div> 6 <CatInlineSvg /> 7 </div> 8); 9 10export default IndexPage;
.svg
. Example: cat.svg
.1import React from "react"; 2import CatSvg from "../images/cat.svg"; 3 4const IndexPage = () => ( 5 <div> 6 <img src={CatSvg} /> 7 </div> 8); 9 10export default IndexPage;
1plugins: [ 2 { 3 resolve: "gatsby-plugin-svgr-svgo", 4 options: { 5 inlineSvgOptions: [ 6 { 7 test: /\.inline.svg$/, 8 svgoConfig: { 9 plugins: [ 10 { 11 name: "preset-default", 12 params: { 13 overrides: [{ name: "removeViewBox", active: false }], 14 }, 15 }, 16 "prefixIds", 17 ], 18 }, 19 }, 20 ], 21 urlSvgOptions: [ 22 { 23 test: /\.svg$/, 24 svgoConfig: { 25 plugins: [{ name: "removeViewBox", active: false }], 26 }, 27 }, 28 ], 29 }, 30 }, 31];
You can declare various rules based on loader that should be used under inlineSvgOptions
and urlSvgOptions
.
test
- pattern that will be used to match file name
svgoConfig
- accepts plugins list with settings, list of available plugins(options) you can find here
svgo
- disables SVGO if set in false
1plugins: [ 2 { 3 resolve: "gatsby-plugin-svgr-svgo", 4 options: { 5 urlSvgOptions: [ 6 { 7 test: /\.svg$/, 8 svgo: false, 9 }, 10 ], 11 }, 12 }, 13];
By default webpack url-loader
has a fallback to file-loader
that converts the file from the original extension to base64. Plugins set default as 512 bytes. So if you want to set the limit from which it should be loaded directly from url instead of base64 loading just use limit option within urlLoaderOptions
.
Limits you set in bytes. Read about more options there
1urlSvgOptions: [ 2 { 3 test: /\.svg$/, 4 svgoConfig: { 5 plugins: [{ name: "removeViewBox", active: false }], 6 }, 7 urlLoaderOptions: { 8 limit: 512, 9 }, 10 }, 11];
No vulnerabilities found.