Next.js Discord

Discord Forum

Cannot import svgs using @svgr/webpack

Unanswered
Polar bear posted this in #help-forum
Open in Discord
Polar bearOP
[Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.] {
  digest: '1564860533'
}


next.config.ts:
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  reactStrictMode: false,
  experimental: {
    turbo: {
      rules: {
        '*.svg': {
          loaders: ['@svgr/webpack'],
          as: '*.js',
        },
      },
    },
  }
};

export default nextConfig;


### In production






I followed the documentation
https://nextjs.org/docs/app/api-reference/config/next-config-js/turbo#webpack-loaders

1 Reply