Skip to content

Instantly share code, notes, and snippets.

@lukebussey
Last active December 1, 2025 16:46
Show Gist options
  • Select an option

  • Save lukebussey/8387bb038629dccc01a62487614f44df to your computer and use it in GitHub Desktop.

Select an option

Save lukebussey/8387bb038629dccc01a62487614f44df to your computer and use it in GitHub Desktop.

To embed the contents of an SVG file into your site using NextJS with the new Rust-based compiler (Turbopack), perform the following steps:

  1. Install @svg/webpack:
$ npm install --save-dev @svgr/webpack
  1. Add to your webpack config in next.config.js with the following options. This will remove the width and height from the SVG but keep the viewBox for correct scaling.
module.exports = {
  turbopack: {
    rules: {
      '*.svg': {
        loaders: [
          {
            loader: '@svgr/webpack',
            options: {
              svgoConfig: {
                multipass: true,
                plugins: ['removeDimensions'],
              },
            },
          },
        ],
        as: '*.js',
      },
    },
  },
}
  1. Import SVG into component
import Logo from 'public/images/logo.svg';
  1. Use the Component
<Logo className="h-8 w-auto sm:h-10" alt="Site Title" />
@0xDamei
Copy link

0xDamei commented Dec 1, 2025

hi friend, what does multipass prop do?
I do not see any prop about this one in https://react-svgr.com/docs/options/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment