Automatic Installation
Let the CLI handle the setup for you:Run the CLI
Navigate to your project root and run:The CLI will detect your Webpack setup and configure React Grab automatically.
Manual Installation
For manual setup or custom configurations:How It Works
Webpack’s conditional compilation and tree-shaking work together to optimize React Grab:- Development: When
process.env.NODE_ENV === "development", the dynamic import executes and React Grab loads - Production: Webpack’s DefinePlugin replaces
process.env.NODE_ENVwith"production", making the condition false - Tree-shaking: Dead code elimination removes the entire import statement from your production bundle
Webpack Configuration
Most Webpack setups include the DefinePlugin by default. If you have a custom configuration, ensure you have:webpack.config.js
Create React App, Next.js with Webpack, and most modern Webpack setups include this configuration automatically.
Common Entry Files
React Grab should be added to your main entry file. Common locations include:src/index.tsxorsrc/index.js(Create React App)src/main.tsxorsrc/main.js(Vite-style projects)src/app.tsxorsrc/app.js(custom setups)- Any file specified as
entryin yourwebpack.config.js
webpack.config.js:
webpack.config.js
Verification
Test React Grab
- Hover over any UI element
- Press ⌘C (Mac) or Ctrl+C (Windows/Linux)
- Verify the context is copied to your clipboard
Common Issues
Module not found: react-grab
Module not found: react-grab
Ensure React Grab is installed:Then restart your dev server.
process.env.NODE_ENV is undefined
process.env.NODE_ENV is undefined
Your Webpack configuration may be missing the DefinePlugin. Add it to your
webpack.config.js:Still loading in production
Still loading in production
Verify your build script sets NODE_ENV to production:On Windows, use
package.json
cross-env:package.json
TypeScript errors
TypeScript errors
If TypeScript complains about the dynamic import, ensure your
tsconfig.json has:Create React App
If you’re using Create React App (CRA), follow the standard manual installation:- Install React Grab:
npm install react-grab - Add the import to
src/index.tsxorsrc/index.js - Start your dev server:
npm start
CRA’s production build automatically strips development-only code, so React Grab will be excluded from your production bundle.
Next Steps
Agent Integration
Connect React Grab to Cursor, Claude, or other AI assistants
Configuration
Customize activation behavior and options
