openui-forge-golisted
Install: claude install-skill OthmanAdi/openui-forge
# OpenUI Forge — Go
Build generative UI apps with a React frontend + Go backend. Streams OpenAI API responses directly via net/http.
## Activation Triggers
- "openui go", "openui golang", "openui go backend"
- "generative ui go", "go streaming ui backend"
## Prerequisites
- Node.js >= 22 (24 LTS recommended) + React >= 18.3.1 (19+ recommended) (frontend)
- Go >= 1.24 (backend; 1.23 and older are out of security support as of Go 1.26)
- `OPENAI_API_KEY` environment variable set
## Quick Start
1. Create the React frontend and install OpenUI deps:
```bash
npm install @openuidev/react-ui @openuidev/react-headless @openuidev/react-lang lucide-react zod
```
2. Generate the system prompt:
```bash
npx @openuidev/cli generate ./src/lib/library.ts --out backend/system-prompt.txt
```
3. Create the Go backend (see Full Code below)
4. Run: `go run main.go` on `:8080`, frontend on `:3000`
## Full Code
### Backend: `backend/go.mod`
```
module openui-backend
go 1.24
require (
github.com/joho/godotenv v1.5.1
)
```
### Backend: `backend/main.go`
```go
package main
import (
"bufio"
"bytes"
"encoding/json"
"fmt"
"log"
"net/http"
"os"
_ "github.com/joho/godotenv/autoload"
)
var systemPrompt string
func init() {
data, err := os.ReadFile("system-prompt.txt")
if err != nil {
log.Fatal("system-prompt.txt not found: ", err)
}
systemPrompt = string(data)
}
func corsMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *h