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-source-locator

v0.1.0

Published

A tool to locate React component source code from the browser.

Readme

React Source Locator

A universal front-end source code locator for React projects, allowing you to click on any element in the development environment and jump directly to the corresponding source code file.

✨ Features

  • 🎯 Accurate a- 🎯 Accurate Location: Uses React Fiber to obtain component information for precise source code location.
  • 🔧 Highly Configurable: Supports custom project paths, editors, hotkeys, and more.
  • 🌍 Universal: Can be used in any React project without modifying the source code.
  • 📝 Multi-Editor Support: Built-in support for VS Code, WebStorm, Cursor, and more.
  • 🐛 Debug Friendly: Provides detailed debugging information.
  • 🚀 Zero Dependencies: Does not rely on any third-party libraries.

📦 Installation

npm install react-source-locator
# or
yarn add react-source-locator
# or
pnpm add react-source-locator

🚀 Quick Start

Initialize the locator in your project's entry file (e.g., index.js or main.js):

import { SourceLocator } from 'react-source-locator';

// Initialize in the project entry file
if (process.env.NODE_ENV === 'development') {
  const sourceLocator = new SourceLocator({
    projectRoot: '/path/to/your/project', // Required
    activationKey: 'alt',                 // Optional, defaults to 'alt'
    debug: true                           // Optional, enables debug mode
  });

  sourceLocator.init();
}

How to Use

  1. Hold down the Alt key (or other configured hotkey).
  2. Click on any element on the page.
  3. The tool will automatically open the corresponding source file in your editor.

⚙️ Configuration

The initSourceLocator function accepts a configuration object with the following options:

interface SourceLocatorOptions {
  /** The root path of your project. Required for resolving source file paths. */
  projectRoot: string;

  /** The activation hotkey. Defaults to 'alt'. */
  activationKey?: 'alt' | 'ctrl' | 'meta';

  /** The preferred editor to open files with. If not set, a selector will be shown. */
  preferredEditor?: string;

  /** Whether to show tooltips. Defaults to true. */
  showTooltip?: boolean;

  /** A list of supported editor configurations. */
  editors?: EditorConfig[];

  /** Whether to enable debug mode. Defaults to false. */
  debug?: boolean;
}

interface EditorConfig {
  /** The name of the editor. */
  name: string;

  /** The protocol used to open files (e.g., 'vscode'). */
  protocol: string;

  /** A URL template with placeholders {absolutePath}, {lineNumber}, {columnNumber}. */
  urlTemplate: string;
}

📖 Usage Examples

Basic Configuration

If you don't specify a preferredEditor, a UI selector will appear on the screen to let you choose an editor.

import { SourceLocator } from 'react-source-locator';

const sourceLocator = new SourceLocator({
  projectRoot: '/path/to/your/project',
  activationKey: 'alt',
  debug: true
});

sourceLocator.init();

Specify a Preferred Editor

Set preferredEditor to automatically open files in your favorite editor.

import { SourceLocator } from 'react-source-locator';

const sourceLocator = new SourceLocator({
  projectRoot: '/path/to/your/project',
  preferredEditor: 'VSCode', // Will prioritize VS Code
  activationKey: 'alt',
  debug: true
});

sourceLocator.init();

Custom Editors

You can also define your own list of editors.

const sourceLocator = new SourceLocator({
  projectRoot: '/path/to/project',
  editors: [
    {
      name: 'MyCoolEditor',
      protocol: 'cool-editor',
      urlTemplate: '{protocol}://open?file={absolutePath}&line={lineNumber}'
    }
  ]
});

sourceLocator.init();

License

MIT