OpenCode is an open-source and experimental real-time web development environment with AI integration that lets you write, preview, and deploy HTML/CSS/JS code instantly. It features:
- ✏️ Live editing with instant preview
- 🤖 AI code generation using OpenRouter
- 🚀 One-click deployment to GitHub & Netlify
- 💾 Local project saving and downloading
- Real-time Preview: See changes as you type
- AI Assistant: Generate code with natural language prompts
- Responsive Layout: Adjustable code/preview panels
- Export Options: Download HTML or deploy directly to platforms
- Customizable: Configure API endpoints and models
- Node.js (v16 or higher)
- npm/yarn
- OpenRouter API key (free tier available)
- Clone the repository:
git clone https://github.com/yourusername/opencode.git
- Install dependencies:
cd opencode npm install
- Create a
.env.local
file:NEXT_PUBLIC_FALLBACK_API_KEY=your_openrouter_key
- Run the development server:
npm run dev
- Write HTML/CSS/JS code in the left panel
- See instant preview in the right panel
- Use the divider to adjust panel sizes
- Type your request in the prompt bar (bottom left)
- Example: "Create a responsive navbar with dropdown"
- Click "Generate" or press Enter
- View and edit the generated code
-
Download HTML:
- Click the download button to save as
index.html
- Click the download button to save as
-
Save to GitHub:
- Configure GitHub token and repo in Settings
- Click "Save to GitHub"
-
Deploy to Netlify:
- Configure Netlify token and site ID in Settings
- Click "Deploy to Netlify"
Access settings via the gear icon to configure:
- OpenRouter API key
- Custom AI models/endpoints
- GitHub credentials
- Netlify credentials
Create .env.local
with these options:
NEXT_PUBLIC_FALLBACK_API_KEY=your_openrouter_key
Edit DEFAULT_CONFIG
in app/page.tsx
to change:
- Default API endpoints
- Starter HTML template
- UI preferences
- Framework: Next.js (App Router)
- UI: Tailwind CSS
- AI Integration: OpenRouter API
- Bundling: Webpack
- Deployment: Vercel (recommended)
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.