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

react-icons-eject

v0.0.10

Published

[![npm](https://img.shields.io/npm/v/react-icons-eject?color=crimson&label=npm)](https://www.npmjs.com/package/react-icons-eject) [![minzipped size](https://img.shields.io/bundlephobia/minzip/react-icons-eject?label=minzipped%20size)](https://www.npmjs.co

Downloads

19

Readme

🧱 react-icons-eject

npm minzipped size downloads types

Tree-shake your react-icons!

This tool scans your project for react-icons usage, extracts only the icons you actually use, and rewrites imports to point to local components — giving you full control over how icons are loaded and potentially improving bundle optimization in frameworks like Next.js.


✨ Features

  • ✅ Replace all react-icons imports with local icon components
  • 🔍 Detect and list all used react-icons in your project
  • ⚙️ Customizable import paths and output directories via config file
  • 🛠️ Designed for TypeScript projects (.ts, .tsx) using ESM

📦 Installation

npm install -g react-icons-eject

Or use without installing globally:

npx react-icons-eject

🚀 Usage

Just run:

react-icons-eject

You'll be prompted with several actions:

1. Replace all react-icons imports with local icon imports

Rewrites your imports like:

import { RiPlayLine } from 'react-icons/ri';

into:

import RiPlayLine from '@/icons/ri/RiPlayLine';

2. Import a single icon from react-icons and generate a local version

Allows you to generate only one icon like ri/RiPlayLine into your custom directory.

3. Scan the project and list all react-icons used

Outputs a icons-list.ts file containing all used icon identifiers in your project.

4. Scan and locally generate all react-icons used in the project

Automatically extracts all icons you're using and generates them locally.


⚠️ Limitations

This tool is designed with the following assumptions:

  • 📁 Your project uses ES module syntax (import / export) — require() and CommonJS are not supported.
  • 🧠 It scans .ts, .tsx, .js, and .jsx files, but:
    • ⚠️ Only ESM-based JavaScript (import { ... } from 'react-icons/ri') is supported
    • ✅ Generated icons are written as .tsx files — intended for TypeScript + React projects

If you're using plain JavaScript and want .js output, feel free to open an issue or submit a PR.


🧩 Configuration

On first run, you'll be prompted to create a react-icon-eject.config.ts file like this:

// react-icon-eject.config.ts
export const config = {
  outputDir: './src/components/icons',             // Directory where icons are written
  importPath: '@/components/icons',                // Path used in rewritten imports
};

GenIcon.tsx and IconContext.tsx will be copied automatically to outputDir (if not already present).


🤔 Why?

Using react-icons out of the box imports entire icon sets like react-icons/ri, which can:

  • Break tree-shaking in some build tools
  • Slow down your dev server and production builds
  • Introduce unnecessary dependencies into your bundle

This tool helps by:

  • Extracting only the icons you actually use
  • Rewriting imports to static, local files
  • Giving you full control over how icons are loaded and used

Related issues

  • https://github.com/react-icons/react-icons/issues/593
  • https://github.com/vercel/next.js/issues/70666

📄 License

MIT – free to use and modify.