Socket
Book a DemoInstallSign in
Socket

@mcansh/next-svgr

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mcansh/next-svgr

easily use @svgr/webpack with next.js

latest
Source
npmnpm
Version
1.3.0
Version published
Maintainers
1
Created
Source

@mcansh/next-svgr

Use @svgr/webpack with Next.js

Installation

npm install @mcansh/next-svgr

or

yarn add @mcansh/next-svgr

Usage

Create a next.config.js in your project

// next.config.js
const withSVG = require("@mcansh/next-svgr")();
module.exports = withSVG();

Optionally you can provide options:

// next.config.js
const withSVG = require("@mcansh/next-svgr")({
  native: true,
  svgoConfig: {
    removeViewBox: true,
  },
});
module.exports = withSVG();

Optionally you can add your custom Next.js configuration as parameter

// next.config.js
const withSVG = require("@mcansh/next-svgr")();
module.exports = withSVG({
  webpack(config, options) {
    return config;
  },
});

TypeScript

TypeScript doesn't know how interpret imported svgs. you need to add reference to our types (third line) into your next-env.d.ts file.

/// <reference types="next" />
/// <reference types="next/types/global" />

+ /// <reference types="@mcansh/next-svgr" />

FAQs

Package last updated on 17 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts