Prerequisites
You must have OpenCode installed to use this integration.
Installation
Start the server
The server runs on port To stop it:
6567 by default.Quick Start (CLI)
Start the server in the background before running your dev server:The server will run as a detached background process. Stopping your dev server (Ctrl+C) won’t stop the React Grab server.
Recommended: Config File Setup
For better lifecycle management, start the server from your config file. This ensures the server stops when your dev server stops:Vite
Next.js
How It Works
- React Grab sends the selected element context to the server via HTTP POST
- Server receives the request and spawns the
opencodeCLI process - OpenCode processes the request and streams JSON responses to stdout
- Server relays status updates to the client via Server-Sent Events (SSE)
Usage
Once installed, you can:- Select an element in your browser by hovering over it with React Grab active
- Right-click or use the context menu to choose “Edit with OpenCode”
- Enter your prompt describing what you want to change
- Watch as OpenCode makes the changes in real-time
- The selected element’s HTML structure
- Component name and file location
- Line numbers for precise targeting
Example Workflow
Select the element
Hover over any UI element in your browser and press Cmd+C (Mac) or Ctrl+C (Windows/Linux).
Advanced Configuration
You can customize the OpenCode provider with advanced options:Configuration Options
-
model: Specify which AI model OpenCode should use- Default:
claude-sonnet-4-20250514 - Other options depend on your OpenCode configuration
- Default:
-
agent: Choose the agent typebuild: Makes direct code changes (default)plan: Creates a plan before executing changes
-
directory: Specify the project directory- Defaults to the current working directory
- Useful for monorepo setups
Server URL
By default, the client connects tohttp://localhost:6567. You can customize this:
Why Use OpenCode with React Grab?
OpenCode provides:- Intelligent code generation: Creates production-ready code
- Context-aware changes: Understands your project structure
- Multiple agent modes: Choose between quick builds or planned changes
- Flexible model selection: Use different AI models for different tasks
Troubleshooting
OpenCode CLI not found
OpenCode CLI not found
Make sure you have installed OpenCode globally:Verify it’s installed:
Server won't start
Server won't start
- Check if port 6567 is already in use
- Try killing existing processes:
pkill -f "react-grab.*server" - Ensure OpenCode is properly installed
No response from OpenCode
No response from OpenCode
- Verify OpenCode is configured correctly
- Check that you have API credentials set up
- Ensure the OpenCode CLI is working:
opencode --help
Context not being sent
Context not being sent
- Verify the client script is loaded in your browser
- Check browser console for connection errors
- Ensure the server is running before loading your app
Wrong directory being modified
Wrong directory being modified
- Set the
directoryoption in your provider configuration - Check the
REACT_GRAB_CWDenvironment variable - Verify the working directory in server logs
Performance Benefits
Using React Grab with OpenCode can make your development workflow up to 3× faster by:- Providing precise element context without manual searching
- Reducing the need for clarification questions
- Including exact file paths and line numbers
- Supporting both quick builds and planned changes
Next Steps
Quick Start
Get started with React Grab
Plugin API
Learn about the plugin system
