next-react-svg
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

Next React Svg

npm version

Transform your svg image to a React component.

Features

  • Svg properties
  • React props and events

Installation

yarn add next-react-svg -E

Note Supports Next.js >= 12

Usage

Create a next.config.js in your project and pass an include to define the svg folder localization.

const path = require('path');

/**
 * @type {import('next-react-svg').NextReactSvgConfig}
 */
const nextReactSvgConfig = {
  include: path.resolve(__dirname, 'src/assets/svg'),
};

/**
 * @type {import('next').NextConfig}
 */
const nextConfig = {
  // ...
};

const withReactSvg = require('next-react-svg')(nextReactSvgConfig);

module.exports = withReactSvg(nextConfig);
import Logo from 'assets/svg/Logo.svg';

export default () => <Logo />;

Typescript

Create an additional.d.ts file at the root of your project. Add the following reference:

/// <reference types="next-react-svg" />

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.2.0
    4,033
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.2.0
    4,033
  • 1.1.3
    1,840
  • 1.1.2
    941
  • 1.1.1
    12
  • 1.1.0
    914
  • 1.0.0
    40

Package Sidebar

Install

npm i next-react-svg

Weekly Downloads

6,325

Version

1.2.0

License

MIT

Unpacked Size

4.11 kB

Total Files

6

Last publish

Collaborators

  • jeremy.barbet