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

nextjs-locator

v0.4.0

Published

Alt+Click any React component to open its source in VS Code. Zero-config for Next.js with Turbopack.

Readme

nextjs-locator

Alt+Click any React component to open its source in your editor.

Zero-config for Next.js 15/16 with Turbopack. No Babel plugin, no browser extension, no setup.

https://github.com/user-attachments/assets/4aa73a8c-ff03-4017-8950-14b70417cea2

Features

  • Zero config — Drop a single component into your layout, done
  • React 18 + 19 — Uses _debugStack (React 19) with _debugSource fallback (React 18)
  • Turbopack native — Decodes Turbopack's sectioned source map format
  • Webpack compatible — Also works with Next.js webpack builds
  • File path tooltip — Shows resolved source file path and line on hover
  • Props/State preview — Hover shows component props, hook state, and render count
  • Component hierarchy — Right-click to see the full React component ancestry with overlay highlight
  • Claude Code integration — "Ask Claude" action sends component context (props, state, DOM, CSS) to Claude Code
  • Source map prefetch — Prefetches source maps on modifier key press for instant resolution
  • Compile-time fast path — Optional nextjs-locator-swc companion for instant resolution via build-time attributes
  • Multi-editor — VS Code, Cursor, WebStorm, Zed, VS Code Insiders
  • Zero dependencies — Only requires react as a peer dependency
  • Production safe — Tree-shaken completely from production builds
  • Configurable — Modifier key, highlight color, editor choice, preview toggle via props

How It Works

  1. Listens for modifier key + mousemove to find the DOM element under cursor
  2. Traverses the React Fiber tree via __reactFiber$ internal key
  3. Source resolution priority:
    • data-locator-source attribute (instant, if nextjs-locator-swc is used)
    • _debugSource (React 18, synchronous)
    • _debugStack + source map (React 19, async with prefetch)
  4. Prefetches .map source maps when modifier key is pressed (Turbopack sections format)
  5. Decodes VLQ mappings to resolve the original file path, line, and column
  6. Displays file path in tooltip and props/state preview panel
  7. Alt+Click opens action picker: go to source or ask Claude
  8. Alt+Right-click shows component hierarchy with hover overlay highlighting
  9. "Ask Claude" collects component context and opens Claude Code via vscode:// protocol

Installation

npm install nextjs-locator
# or
yarn add nextjs-locator
# or
pnpm add nextjs-locator

Quick Start

Next.js App Router

// app/layout.tsx
import { Locator } from 'nextjs-locator';

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html>
      <body>
        {children}
        <Locator />
      </body>
    </html>
  );
}

Next.js Pages Router

// pages/_app.tsx
import { Locator } from 'nextjs-locator';
import type { AppProps } from 'next/app';

export default function App({ Component, pageProps }: AppProps) {
  return (
    <>
      <Component {...pageProps} />
      <Locator />
    </>
  );
}

Keyboard Shortcuts

| Shortcut | Action | |----------|--------| | Alt + Hover | Highlight component with name and source file path | | Alt + Click | Open action picker (go to source / ask Claude) | | Alt + Right-click | Show component hierarchy menu with overlay highlight | | Arrow Up/Down | Navigate menu items | | Enter | Select action | | Escape | Dismiss menu |

On Mac, use Option instead of Alt.

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | editor | EditorProtocol | 'vscode' | Editor to open files in | | modifier | 'alt' \| 'ctrl' \| 'meta' \| 'shift' | 'alt' | Modifier key to activate | | highlightColor | string | '#ef4444' | CSS color for the overlay border | | projectRoot | string | — | Absolute project root path | | enabled | boolean | true in dev | Force enable/disable | | showPreview | boolean | true | Show props/state preview on hover |

Editor Support

| Editor | editor value | Protocol | |--------|----------------|----------| | VS Code | 'vscode' | vscode://file | | Cursor | 'cursor' | cursor://file | | VS Code Insiders | 'vscode-insiders' | vscode-insiders://file | | WebStorm | 'webstorm' | webstorm://open?file= | | Zed | 'zed' | zed://file |

<Locator editor="cursor" />

Configuration

Project Root

If source map paths don't resolve correctly (e.g., in monorepos or custom setups), set the project root:

Option 1: Via prop

<Locator projectRoot="/Users/you/projects/my-app" />

Option 2: Via environment variable

# .env.local
NEXT_PUBLIC_PROJECT_ROOT=/Users/you/projects/my-app

Custom Modifier Key

<Locator modifier="ctrl" />    {/* Ctrl+Click */}
<Locator modifier="meta" />    {/* Cmd+Click (Mac) / Win+Click */}
<Locator modifier="shift" />   {/* Shift+Click */}

Custom Highlight Color

<Locator highlightColor="#3b82f6" />   {/* Blue */}
<Locator highlightColor="#10b981" />   {/* Green */}

Claude Code Integration

Alt+Click any component to open the action picker, then select "Claude에게 묻기" (Ask Claude). A modal appears where you can type your instruction (e.g., "change this button to blue"). The prompt sent to Claude Code includes:

  • Component name, file path, and line number
  • Current props and hook state (useState, useReducer, useRef, useMemo)
  • Rendered DOM HTML structure
  • Key computed CSS properties

This opens Claude Code in VS Code with the full component context pre-filled, so Claude can make targeted edits to the right file.

Comparison with Alternatives

| Feature | nextjs-locator | click-to-react-component | LocatorJS | react-dev-inspector | |---------|---------------|--------------------------|-----------|---------------------| | React 19 support | Yes | No | Partial | No | | React 18 support | Yes (_debugSource) | Yes | Yes | Yes | | Turbopack support | Yes | No | No | No | | Setup | Drop-in component | Babel plugin | Browser ext + Babel | Babel/SWC plugin | | File path tooltip | Yes | No | No | No | | Props/State preview | Yes | No | No | No | | Component hierarchy | Yes (right-click) | Yes | No | No | | Claude Code integration | Yes | No | No | No | | Source map prefetch | Yes | N/A | N/A | N/A | | Compile-time fast path | Yes (optional) | N/A | N/A | N/A | | Dependencies | 0 | Small | Extension | Plugin | | Next.js App Router | Native | Needs config | Partial | Needs config | | Multi-editor | 5 editors | VS Code only | VS Code + others | VS Code + others |

Requirements

  • React >= 18.0.0
  • Next.js 13+ (App Router recommended)
  • Development mode only (completely removed in production)

How is this different?

vs click-to-react-component

Requires @babel/plugin-transform-react-jsx-source which injects _debugSource into every JSX element at compile time. React 19 removed _debugSource in favor of _debugStack, breaking this approach. nextjs-locator reads _debugStack natively and falls back to _debugSource for React 18 — no build plugin needed.

vs LocatorJS

Requires a browser extension or Babel plugin to inject data-locator attributes. Doesn't support Turbopack's sectioned source map format. nextjs-locator works by decoding source maps at runtime — zero build-time setup.

vs react-dev-inspector

Requires SWC/Babel plugin configuration. nextjs-locator achieves the same result with zero config by leveraging React's built-in debug information and runtime source map resolution. Plus, it offers component hierarchy navigation and file path preview that others don't.

Props/State Preview

When hovering a component with the modifier key held, a preview panel appears showing:

  • Props — Current prop values (max 10, excluding children)
  • Hook stateuseState, useReducer, useMemo, useRef values
  • Render count — How many times the component has been inspected

Disable with:

<Locator showPreview={false} />

Compile-Time Source Resolution (Optional)

For instant source resolution without runtime source map fetching, install the companion package:

npm install nextjs-locator-swc
// next.config.js
const { withLocator } = require('nextjs-locator-swc');
module.exports = withLocator({ /* your config */ });

This injects data-locator-source attributes at build time, which nextjs-locator reads directly for zero-latency clicks. See nextjs-locator-swc for details.

TypeScript

Full TypeScript support with exported types:

import type { LocatorProps, EditorProtocol, FiberInspection } from 'nextjs-locator';

License

MIT