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-component-grep

v1.0.17

Published

<p align="center"> <a href="https://react-grep.com"> <h1 align="center">react-component-grep</h1> </a> </p>

Readme

  • Inspect - Hold Cmd (Mac) / Ctrl (Windows/Linux) and hover over any element to see the React component name and source file location
  • Open Mac - Cmd+Click to open the active file path and line number to your code editor(vscode)
  • Open Windows/Linux - Ctrl+Click to open the active file path and line number to your code editor(vscode)

Works with Vite + React & React Native For Web app in development mode.

Install

# npm
npm install react-component-grep --save-dev

Usage

Vite+React app

-----------------
# vite.config.js
-----------------
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";

import reactComponentGrep from "react-component-grep/vite";  // <--- Add this line

export default defineConfig({
  plugins: [ 
    reactComponentGrep(),  // <--- Add this line
    react()
  ]
});


-----------
# main.jsx
-----------
import "react-component-grep";  // <--- Add this line

React Native Setup

---------
#App.js
--------
import { ReactComponentGrepOverlay } from 'react-component-grep/native' // <--- Add this line

return (
  <>
    {__DEV__ && <ReactComponentGrepOverlay metroPort={8081} />} // <--- Add this line
  </>
)


-----------------
#babel.config.js 
-----------------
module.exports = function (api) {                  // <--- Replace with this
  const isDev = api.env("development");
  return {
    presets: [
      'module:@react-native/babel-preset'
    ],
    plugins: [
      isDev && 'react-component-grep/babel',
      isDev && '@babel/plugin-transform-react-jsx-source'
    ].filter(Boolean),
  };
};

-----------------
#metro.config.js
----------------
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
const { execSync } = require("child_process") // <--- Add this line

// Replace with below config
/**
 * Metro configuration
 * https://reactnative.dev/docs/metro
 *
 * @type {import('@react-native/metro-config').MetroConfig}
 */
const config = {
    server: {
        enhanceMiddleware: (middleware) => {
            return (req, res, next) => {
                if (req.url.startsWith('/open-in-vscode')) {
                    const params = new URL(req.url, 'http://localhost').searchParams;
                    const file = params.get('file');
                    const line = params.get('line') || '1';
                    if (file) {
                        try {
                            execSync(`code -g "${file}:${line}"`);
                        } catch (e) {
                            try {
                                execSync(`open "vscode://file/${file}:${line}:1"`)
                            } catch { }
                        }
                    }
                    res.writeHead(200, {
                        'Content-Type': 'text/plain',
                        'Access-Control-Allow-Origin': '*'
                    })
                    res.end('ok');
                    return;
                }
                return middleware(req, res, next);
            }
        }
    }
};

module.exports = mergeConfig(getDefaultConfig(__dirname), config);


-------------------
#webpack.config.js
-------------------

const babelLoaderConfiguration = {
  ...
    exclude: /node_modules[\/\\]react-component-grep[\/\\]dist[\/\\]native/,  <--- Add this line
  ...
}

React Native For Web Setup

----------------------
#babel.config.web.js
---------------------
plugins: ["react-component-grep/babel", "@babel/plugin-transform-react-jsx-source"]  // <--- Add this line

//or

const isDev = process.env.NODE_ENV === 'development' || process.argv.includes('serve'); <--- Add this line
module.exports = {
    presets: ['module:@react-native/babel-preset'],
    plugins: [
        ...(isDev ? ["react-component-grep/babel"] : []), <--- Add this line
        'react-native-web',
        [
            'module-resolver',
            {
                alias: {
                    '^react-native$': 'react-native-web',
                },
            },
        ],
        ...(isDev ? ["@babel/plugin-transform-react-jsx-source"] : []) <--- Add this line
    ],
}

------------
#App.web.js
------------
import "react-component-grep"; <--- Add this line

//or

if (__DEV__) {
    require("react-component-grep") <--- Add this line
}

-------------------
#webpack.config.js
-------------------
const compileNodeModules = [

    // Add every react-native package that needs compiling
    
    'react-component-grep',  <--- Add this line

].map((moduleName) => path.resolve(appDirectory, `node_modules/${moduleName}`));

const babelLoaderConfiguration = {
  ...
  
  exclude: /node_modules[\/\\]react-component-grep/,  <--- Add this line
  
  ...
}

// Add below object
const reactComponentGrepRuntimeConfiguration = {
  test: /react-component-grep[\/\\/]dist[\/\\]runtime[\/\\].*\.js$/,
  type: 'javascript/auto',
  use: {
    loader: 'babel-loader',
    options: {
      cacheDirectory: true,
      presets: ['module:@react-native/babel-preset'],
      plugins: ['react-native-web'],
    },
  },
};

// add reactComponentGrepRuntimeConfiguration in rules array
module.exports = (env) => ({
  ...

  module: {
    rules: [
      reactComponentGrepRuntimeConfiguration,
    ]
  }

  ....
})

How it works

When the modifier key is held:

  1. The hovered DOM element is highlighted with a blue overlay
  2. A tooltip shows the component name, file path, and line number (if available)
  3. Cmd+Click or Ctrl+Clickt opens the active file:line to code editor

License

MIT