Install the Next SVG Sprite package with the needed dependencies: npm i next-svg-sprite svg-sprite-loader svg-baker-runtime
Import the plugin in the next.config.js
file via:
const withSvgSprite = require("next-svg-sprite");
[...]
module.exports = withSvgSprite({})
If your are using Typescript declare a module for the query string imports: declare module "*.svg?sprite";
import MyIcon from 'icons/icon.svg?sprite'
[...]
return (
<>
<MyIcon width="30" height="30">
</>
)