Default: Ctrl + Click β’ Fully configurable
A lightweight Vite plugin that lets you hover any JSX element, inspect its source location, and jump directly to the exact line in your editor.
If React renders it, Locator can locate it.
- β‘ Single Babel AST traversal per file β fast, deterministic, stable SHA1-based ids
- βοΈ Every HTML element, every SVG element, and every React component
- π§© Function components, arrow components,
memo(),forwardRef(),lazy(),Suspense, Portals (createPortal) - π³ Full parent/child DOM hierarchy and component ownership per element
- π Understands how an element was rendered β
.map()/.filter().map()/flatMap(), nested arrays,&&, ternaries, andswitchcases - πͺ Tracks all React hooks (including custom
useXxxhooks) used by each component - π¦ Hover overlay with component name, file, and line
- π±οΈ Ctrl + Click (fully configurable) opens the exact source location in your editor
- π§ VS Code, Cursor, and Windsurf supported out of the box
- π¦ Development only β the transform, registry, and runtime never ship to production
- π Strict TypeScript, zero
any, zero runtime dependency on Node internals in the browser bundle
π‘ Works only in development mode (
apply: "serve"). Nothing is included in your production build.
npm install -D vite-react-locatoror
pnpm add -D vite-react-locatoror
yarn add -D vite-react-locator| Tool | Version / Status |
|---|---|
| Vite | ^6.0.0 || ^7.0.0 |
| React | 17+ |
| TypeScript | β Supported |
| JavaScript | β
Supported (.jsx) |
| Development Mode | β Supported |
| Production Build | Not included |
// vite.config.ts
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import locator from "vite-react-locator";
export default defineConfig({
plugins: [
react(),
locator(),
],
});Import the runtime once in your application entry file (for example main.tsx, main.jsx, index.tsx, or index.jsx).
import "vite-react-locator/runtime";Example:
// main.tsx
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
import "vite-react-locator/runtime";
ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>
<App />
</React.StrictMode>,
);npm run devπ‘ The runtime import is required only during development. It has no effect on your production build.
- Hold the configured activation key (default: Ctrl).
- Hover over any JSX element β HTML, SVG, or a component.
- A blue overlay and tooltip appear showing the component, file, and line.
- Click the highlighted element.
- It opens instantly in VS Code, Cursor, or Windsurf.
React/TSX source
β
βΌ
Single Babel traversal (transform/)
β component detection Β· JSX classification
β hierarchy tracking Β· hook tracking
βΌ
Stable SHA1 locator ids injected as data-locator-id
β
βΌ
Registry served over /__locator + /__locator-options
β
βΌ
Runtime (browser) hovers via data-locator-id, shows overlay
β
βΌ
Ctrl + Click β POST /__open { file, line, column }
β
βΌ
Dev server opens the file in VS Code / Cursor / Windsurf
src/
index.ts β Vite plugin: transform hook, HTML injection, dev-server wiring
shared/ β constants, hashing, tag classification, shared types
transform/ β single-pass Babel visitor: components, JSX, hierarchy, hooks, injection
runtime/ β browser code: hover overlay, activation-key handling, open requests
server/ β dev-server routes (/__locator, /__locator-options, /__open) + editors
tests/ β vitest suite
The transform runs once per file (enforce: "pre", before @vitejs/plugin-react), tags every JSX element with a content-addressed id, and records its metadata β tag, kind (html / svg / component / fragment / portal), owning component, parent/child hierarchy, hooks, and how it was rendered (normal / map / array / logical / ternary / conditional).
| Editor | Status |
|---|---|
| VS Code | β |
| Cursor | β |
| Windsurf | β |
The editor is auto-detected from TERM_PROGRAM, falling back to trying cursor, windsurf, then code on the $PATH.
npm install
npm run build # tsup β bundles src/index.ts and src/runtime/index.ts
npm run test # vitest
npm run lint # eslintThe example/ app is a working Vite + React project wired to consume the local plugin as a real file: dependency, useful for end-to-end verification against a real dev server.
Contributions are welcome.
- Fork the repository
- Create your feature branch
git checkout -b feature/amazing-feature- Commit your changes
git commit -m "feat: add amazing feature"- Push and open a Pull Request.
Please open an issue on GitHub and include:
- Vite version
- React version
- Operating system
- Steps to reproduce
MIT License Β© Shivam Singh
Made with β€οΈ by Shivam Singh


