npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

svgr-react-icons

v1.0.6

Published

A dynamic SVG icon package for React with size and fill customization

Readme

svgr-react-icons

npm downloads license

A lightweight and flexible React SVG icon library with customizable size and color. Import SVGs directly as React components (via SVGR) or load them dynamically from URLs. Works seamlessly with Vite, Next.js, CRA, and Node.js thanks to dual ESM + CJS outputs.

Note: This package replaces [email protected]. The old package is now deprecated. Please migrate to svgr-react-icons.


✨ Features

  • 🎨 Customizable — control icon size and fill color
  • ⚡ Dual usage — import as React components or load from URLs
  • 🔒 Safe by default — sanitizes SVGs with dompurify
  • 📦 Compatible everywhere — ships ESM (import) and CJS (require)

📦 Installation

yarn add svgr-react-icons dompurify
yarn add --dev vite-plugin-svgr
  • svgr-react-icons → the icon library
  • dompurify → sanitizes dynamic SVGs
  • vite-plugin-svgr → enables importing SVGs as React components

🚀 Quick Start

1. Configure Vite / Next.js

Configure Vite

vite.config.ts

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import svgr from "vite-plugin-svgr";

export default defineConfig({
  plugins: [
    react(),
    svgr({
      svgrOptions: { icon: true, exportType: "default" },
      include: "**/*.svg?react",
    }),
  ],
});

Configure Next.js

next.config.ts

import type { NextConfig } from "next";
const nextConfig: NextConfig = {
  webpack(config) {
    config.module.rules.push({
      test: /\.svg$/,
      issuer: /\.[jt]sx?$/,
      use: ["@svgr/webpack"],
    });
    return config;
  },
};
export default nextConfig;

2. Add an SVG file

src/assets/my-icon.svg

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
  <circle cx="12" cy="12" r="10" />
</svg>

🔧 Usage Examples

Example 1 — Importing SVGs as React Components (SVGR)

import React from "react";
import { Icon } from "svgr-react-icons"; // ESM import
import MyIcon from "./assets/my-icon.svg?react";

export default function App() {
  return <Icon src={MyIcon} size={32} fill="blue" alt="Blue Circle" />;
}

📦 CommonJS alternative (Node / Jest / older setups):

const { Icon } = require("svgr-react-icons");
const MyIcon = require("./assets/my-icon.svg?react");

function App() {
  return <Icon src={MyIcon} size={32} fill="blue" alt="Blue Circle" />;
}

Example 2 — Loading SVGs from a URL

import React from "react";
import { Icon, generateSvgUrl } from "svgr-react-icons";

export default function App() {
  return (
    <Icon
      src={generateSvgUrl("/assets/my-icon.svg")}
      size={48}
      fill="red"
      isUrl
      alt="Red Circle"
    />
  );
}

📑 Icon Component Props

| Prop | Type | Description | Default | | ------- | --------------------------------- | -------------------------------------- | ------- | | src | React.ComponentType or string | SVG component (SVGR) or URL string | — | | size | number | Icon size in pixels (width and height) | 24 | | fill | string | Fill color (e.g., blue, #ff0000) | — | | isUrl | boolean | Set to true for URL-based SVGs | false | | alt | string | Accessibility alt text | — |


🛠 Development & Contributing

Clone and run locally:

git clone https://github.com/gyawali9/svgr-react-icons.git
cd svgr-react-icons
yarn install
yarn build
yarn test

Run example app:

cd example
yarn dev

Open http://localhost:5173


📜 License

MIT © 2025 Roshan Gyawali