🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

@newhighsco/next-plugin-svgr

Package Overview
Dependencies
Maintainers
0
Versions
166
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@newhighsco/next-plugin-svgr

Next.js plugin for transforming SVGs into React components using SVGR

3.0.157
latest
Source
npm
Version published
Weekly downloads
3.7K
6.73%
Maintainers
0
Weekly downloads
 
Created
Source

next-plugin-svgr NPM version

Next.js plugin for transforming SVGs into React components using SVGR

Installation

Install Next.js and @newhighsco/next-plugin-svgr:

npm install --save next @newhighsco/next-plugin-svgr

Usage

Create a next.config.js in your project:

// next.config.js
const withSvgr = require('@newhighsco/next-plugin-svgr')
module.exports = withSvgr({
  svgrOptions: {
    /* config options here */
  }
})

In your code:

import starUrl, { ReactComponent as Star } from './star.svg'

const App = () => (
  <>
    <img src={starUrl} alt="star" />
    <Star />
  </>
)

With TypeScript

In your next-env.d.ts file (or in another type declaration file of your choosing that's within the include section of your tsconfig.js), simply add the following:

declare module '*.svg' {
  import { FC, SVGProps } from 'react';
  export const ReactComponent: FC<SVGProps<SVGSVGElement>>;

  const src: string;
  export default src;
}

This notifies the compiler of the 2 possible ways you're able to import and use SVG files with this plugin integrated.

Options

See options supported by SVGR

CHANGELOG

FAQs

Package last updated on 04 Mar 2025

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