index.html file.
Automatic Installation
The quickest way to get started:Run the CLI
Navigate to your project root (where The CLI will automatically detect your Vite setup and configure React Grab.
vite.config.ts is located) and run:Manual Installation
If you need to manually integrate React Grab into your Vite project:Update your index.html
Add the following script inside the
<head> section of your index.html:index.html
How It Works
Vite’s module system allows for dynamic imports usingimport.meta.env.DEV:
- Development: When
import.meta.env.DEVistrue, React Grab loads and activates - Production: When building for production, the condition is
falseand the import is stripped out - Type-safe: The module script ensures proper ES module handling
- Vite can optimize and bundle the import
- No external network requests needed
- Better caching and hot module replacement (HMR) support
Vite Configuration
No additional Vite configuration is required. React Grab works out of the box with:- React
- Preact
- SolidJS
- Vue (with JSX)
- Any other framework using Vite
Verification
Confirm React Grab is working correctly:Test the copy feature
- Hover over any UI element
- Press ⌘C (Mac) or Ctrl+C (Windows/Linux)
- Check your clipboard for the copied context
Common Issues
Module not found error
Module not found error
Make sure you’ve installed Then restart your dev server.
react-grab as a dependency:Script tag placement
Script tag placement
The script must be placed in the
<head> section, before your main app script. This ensures React Grab loads before your React components.TypeScript errors
TypeScript errors
If you see TypeScript errors related to
import.meta.env, ensure your tsconfig.json includes:Not working with Vitest
Not working with Vitest
React Grab is designed for browser environments. It should not affect Vitest tests since they run in Node.js. If you encounter issues, check that your test setup doesn’t try to import the index.html.
Alternative: Import in Entry File
If you prefer not to modifyindex.html, you can import React Grab in your main entry file:
src/main.tsx
Next Steps
Connect to Your Agent
Integrate React Grab with your AI coding assistant
Customize Settings
Configure activation keys and behavior
