# @svgr-rs/core

> SVGR RS

Latest version **0.0.13** (published 2024-09-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install @svgr-rs/core
pnpm add @svgr-rs/core
yarn add @svgr-rs/core
bun add @svgr-rs/core
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.13 |
| Published | 2024-09-22 |
| First published | 2023-04-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >= 10 |
| Dependencies | 0 |
| Unpacked size | 17.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 59 |
| Author | SyMind |
| Maintainers | qidanta, symind |
| Keywords | svgr, svg, react, core, api, swc |

## Links

- npm: https://www.npmjs.com/package/@svgr-rs/core
- Repository: https://github.com/SyMind/svgr-rs
- Issues: https://github.com/SyMind/svgr-rs/issues
- npm.io page: https://npm.io/package/@svgr-rs/core

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.0.13 (latest) — 2024-09-22
- 0.0.12 — 2023-07-09
- 0.0.11 — 2023-06-30
- 0.0.9 — 2023-05-29
- 0.0.8 — 2023-05-02
- 0.0.7 — 2023-05-02
- 0.0.6 — 2023-05-01
- 0.0.5 — 2023-04-28
- 0.0.4 — 2023-04-27
- 0.0.3 — 2023-04-16

## README

<h1 align="center">SVGR RS</h1>

<p align="center">Speedy SVGR rewritten in Rust 🦀</p>

If you are using SVGR RS from Rust, see [rustdoc](https://docs.rs/svgr-rs/0.1.2/svgr_rs/) and for most uses.

# Webpack

SVGR RS provides an [webpack](https://webpack.js.org/) loader to import SVG as React components.

## Install

```sh
npm install --save-dev @svgr-rs/svgrs-plugin
# or use yarn
yarn add --dev @svgr-rs/core
```

## Usage

webpack.config.js

```js
{
  test: /\.svg$/i,
  issuer: /\.[jt]sx?$/,
  resourceQuery: /react/,
  use: [
    {
      loader: '@svgr-rs/svgrs-plugin/webpack',
      options: {
        exportType: 'named',
        namedExport: 'ReactComponent',
      },
    },
  ],
}
```

# Vite

SVGR RS provides an [vite](https://vitejs.dev/) plugin to import SVG as React components.

## Install

```sh
npm install --save-dev @svgr-rs/svgrs-plugin
# or use yarn
yarn add --dev @svgr-rs/core
```

## Usage

vite.config.js

```js
import react from '@vitejs/plugin-react'
import { svgrs } from '@svgr-rs/svgrs-plugin/vite'
import { defineConfig } from 'vite'

export default defineConfig({
  plugins: [
    react(),
    svgrs({
      exportType: 'named',
      namedExport: 'ReactComponent',
    })
  ],
})
```

# Node.js

Use SVGR RS in Node.js to complex transformations or tools.

## Install

```sh
npm install --save-dev @svgr-rs/core
# or use yarn
yarn add --dev @svgr-rs/core
```

## Usage

Import `transform` from `@svgr-rs/core` to transform a file. It takes three arguments:

* `source`: the SVG source code to transform
* `options`: the options used to transform the SVG
* `state`: a state linked to the transformation

```js
import { transform } from '@svgr-rs/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>
`

const jsCode = await transform(
  svgCode,
  { icon: true },
  { componentName: 'MyComponent' },
)
```

# Benchmarks

Transform time without SVGO and Prettier in W3C SVG 1.1 TestSuite:

![Transform time](./snapshots/transform-time.png)

# Roadmap

- [x] jsxRuntime
- [x] jsxRuntimeImport
- [x] icon
- [x] native
- [x] typescript
- [x] dimensions
- [x] expandProps
- [ ] prettier
- [ ] prettierConfig
- [ ] svgo ([Speedy SVGO rewritten in Rust](https://github.com/svg-rust/svgo-rs) is working in progress)
- [ ] svgoConfig
- [x] ref
- [x] memo
- [x] replaceAttrValues
- [x] svgProps
- [x] titleProp
- [x] descProp

# License

[MIT](./LICENSE)

---
_Source: https://npm.io/package/@svgr-rs/core · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
