Install Locator for React

Install Locator on React codebase. This is DevTools variant which is preffered solution. Alternative is data-id solution.

Both browser extension and library require either working devtools with sources or Locator's Babel plugin.
A

Browser extension (option A)

Easiest way to start with Locator is to install a Browser Extension
You can get extension for Chrome, Edge, Brave, Opera, Firefox
B

Library (option B)

If you would like to install Locator to your project, so all team members can use it. You can install it as a library.
npm install -D @locator/runtime
Add this to pages/_app.jsx (or other global file):
import setupLocatorUI from "@locator/runtime";

if (process.env.NODE_ENV === "development") {
  setupLocatorUI();
}
3

Next.js 15+ with Turbopack/SWC

For Next.js 15+ using Turbopack or SWC (where babel plugins don't work), use the webpack/turbopack loader:
npm install -D @locator/webpack-loader
For Turbopack (Next.js 15+):
Add this to your next.config.ts:
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  turbopack: {
    rules: {
      "**/*.{tsx,jsx}": {
        loaders: [{
          loader: "@locator/webpack-loader",
          options: { env: "development" }
        }]
      }
    }
  }
};

export default nextConfig;
For Webpack:
Add this to your next.config.js:
module.exports = {
  webpack: (config, { isServer }) => {
    if (!isServer) {
      config.module.rules.push({
        test: /\.(tsx|ts|jsx|js)$/,
        exclude: /node_modules/,
        use: [{
          loader: '@locator/webpack-loader',
          options: { 
            env: 'development'
          }
        }]
      });
    }
    return config;
  }
};
?

Troubleshooting

Locator should work automatically in dev mode in most modern stacks. They automatically include babel-preset-react which includes babel-plugin-transform-react-jsx-source
Non-babel stacks use similar alternatives.

If you don't have babel-plugin-transform-react-jsx-source you should set it up manually.
tl;dr Adding this to your Babel config might help:
{
  "presets": ["@babel/preset-react"],
  "plugins": [
    "@babel/plugin-transform-react-jsx-self",
    "@babel/plugin-transform-react-jsx-source"
  ]
}

Or try alternative: installation based on custom Babel plugin