Socket
Socket
Sign inDemoInstall

@svgr/core

Package Overview
Dependencies
82
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@svgr/core

Transform SVG into React Components.


Version published
Maintainers
1
Weekly downloads
7,420,069
decreased by-6.99%

Weekly downloads

Readme

Source

@svgr/core

Build Status version MIT License

Node API of SVGR.

npm install @svgr/core

Usage

import { transform } from '@svgr/core'

const svgCode = `
<svg xmlns="http://www.w3.org/2000/svg"
  xmlns:xlink="http://www.w3.org/1999/xlink">
  <rect x="10" y="10" height="100" width="100"
    style="stroke:#ff0000; fill: #0000ff"/>
</svg>
`

transform(svgCode, { icon: true }, { componentName: 'MyComponent' }).then(
  (jsCode) => {
    console.log(jsCode)
  },
)

Use svgr.sync(code, config, state) if you would like to use sync version.

Plugins

By default @svgr/core doesn't include any plugin, if you want them, you have to install them and include them in config.

svgr(svgCode, {
  plugins: ['@svgr/plugin-svgo', '@svgr/plugin-jsx', '@svgr/plugin-prettier'],
}).then((jsCode) => {
  console.log(jsCode)
})

License

MIT

Keywords

FAQs

Last updated on 15 Aug 2023

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc