Grab any element in your app and give it to Cursor, Claude Code, or other AI coding agents.
Install React Grab in a React project to enable element grabbing for AI coding agents.
- React Grab package is installed
- Framework integration is configured (Next.js, Vite, SvelteKit, or Webpack)
- Running the dev server shows the grab overlay when pressing the activation key
Run this command at your project root. Use the -y flag to skip interactive prompts:
npx grab@latest init -yThe CLI will auto-detect your framework and configure everything automatically.
Options:
-f, --framework Override detected framework [choices: "next", "vite", "sveltekit", "webpack"]
-p, --package-manager Override detected package manager [choices: "npm", "yarn", "pnpm", "bun"]
-r, --router Next.js router type [choices: "app", "pages"]
-k, --key Activation key (e.g., "Meta+K", "Ctrl+Shift+G", "Space")
-y, --yes Skip all prompts and use auto-detected/default values
--skip-install Only modify config files, skip package install
npx grab@latest init -y # Auto-detect and install without prompts
npx grab@latest init -f next -r app -y # Configure for Next.js App Router
npx grab@latest init -k "Meta+K" -y # Set activation key to Cmd+K / Win+KIf CLI fails, install manually based on your framework:
npm install react-grab@latest
# or yarn add react-grab@latest
# or pnpm add react-grab@latest
# or bun add react-grab@latestAdd to app/layout.tsx:
import Script from "next/script";
export default function RootLayout({ children }) {
return (
<html>
<head>
{process.env.NODE_ENV === "development" && (
<Script
src="//unpkg.com/react-grab/dist/index.global.js"
crossOrigin="anonymous"
strategy="beforeInteractive"
/>
)}
</head>
<body>{children}</body>
</html>
);
}Add to pages/_document.tsx:
import { Html, Head, Main, NextScript } from "next/document";
export default function Document() {
return (
<Html lang="en">
<Head>
{process.env.NODE_ENV === "development" && (
<Script
src="//unpkg.com/react-grab/dist/index.global.js"
crossOrigin="anonymous"
strategy="beforeInteractive"
/>
)}
</Head>
<body>
<Main />
<NextScript />
</body>
</Html>
);
}Add to your main entry file (e.g., src/main.tsx):
if (import.meta.env.DEV) {
import("react-grab");
}Add to src/hooks.client.ts:
if (import.meta.env.DEV) {
import("react-grab");
}Add to your main entry file (e.g., src/index.tsx):
if (process.env.NODE_ENV === "development") {
import("react-grab");
}- Start your development server
- Open your app in the browser
- Hover over any UI element and press Cmd+C (Mac) or Ctrl+C (Windows/Linux)
- The element's context should be copied to your clipboard
Expected clipboard output format:
<a class="ml-auto inline-block text-sm" href="#">
Forgot your password?
</a>
in LoginForm at components/login-form.tsx:46:19
Customize React Grab behavior:
npx grab@latest config -k "Meta+K" # Set activation key to Cmd+K / Win+K
npx grab@latest config -m hold --hold-duration 150 # Use hold mode with 150ms delay
npx grab@latest config --context-lines 5 # Include 5 lines of context- Overlay not showing: Ensure you're in development mode (
NODE_ENV=development) - Copy not working: Check if another extension is capturing the keyboard shortcut
- Framework not detected: Use
-fflag to specify framework manually
- Documentation: https://react-grab.com/llms.txt
- GitHub: https://github.com/aidenybai/react-grab