Skip to main content

Installation

React Grab can be installed automatically using the CLI or manually for more control. The easiest way to install React Grab is using the CLI tool:
Run this command from your project root directory (where next.config.ts or vite.config.ts is located).

What the CLI Does

The initialization command automatically:
  1. Detects your framework - Identifies Next.js, Vite, TanStack Start, or Webpack
  2. Detects your package manager - Works with npm, yarn, pnpm, or bun
  3. Installs dependencies - Adds react-grab package
  4. Configures your project - Modifies necessary files to load React Grab in development
  5. Shows a diff - Previews all changes before applying them

CLI Options

Customize the installation with these flags:
  • -y, --yes - Skip confirmation prompts
  • -f, --force - Force overwrite existing configuration
  • -a, --agent <agent> - Connect to your agent (cursor, claude, copilot, mcp)
  • -k, --key <key> - Set custom activation key (e.g., Meta+K, Ctrl+Shift+G, Space)
  • --skip-install - Skip package installation
  • -c, --cwd <cwd> - Specify working directory

Examples

Manual Installation

If you prefer manual installation or the automatic setup doesn’t work for your setup, follow the framework-specific instructions below.

Next.js (App Router)

Add this to your app/layout.tsx:
app/layout.tsx
The beforeInteractive strategy ensures React Grab loads before your application, capturing all component renders.

Next.js (Pages Router)

Add this to your pages/_document.tsx:
pages/_document.tsx

Vite

Add this to your index.html:
index.html
Vite’s import.meta.env.DEV ensures React Grab only loads in development mode.

Webpack

1

Install React Grab

First, install the package:
2

Import in your entry file

Add this at the top of your main entry file (e.g., src/index.tsx or src/main.tsx):
src/index.tsx

Package Managers

React Grab works with all major package managers:

Verification

After installation, verify React Grab is working:
1

Start your development server

2

Open your application

Navigate to your application in a browser (usually http://localhost:3000 or http://localhost:5173).
3

Test element selection

Hover over any UI element and press:
  • ⌘C on Mac
  • Ctrl+C on Windows/Linux
You should see a visual indicator when hovering, and the context should be copied to your clipboard.
4

Verify clipboard content

Paste the clipboard content into a text editor. You should see output like:
If React Grab doesn’t appear, check:
  • You’re running in development mode
  • The script is loading (check browser network tab)
  • No console errors are present
  • You’re hovering before pressing the activation key

Monorepo Support

For monorepos, the CLI automatically detects all React projects:
You’ll be prompted to select which project to install React Grab into. To skip the prompt:

Agent Integration

Connect React Grab to your coding agent:

MCP Integration

For agents supporting Model Context Protocol:
This configures your agent to automatically access React Grab context.

Manual Agent Setup

When installing, you can specify an agent:
Supported agents:
  • cursor - Cursor AI
  • claude - Claude Code
  • copilot - GitHub Copilot
  • mcp - Model Context Protocol

Next Steps

Quick Start

Learn how to use React Grab effectively

GitHub Repository

View source code and contribute