Web Development
irgo apps work as standard web applications out of the box. The web mode is primarily used for development, but can also be deployed as a traditional web server.
Development Server
irgo devThis starts a web server at http://localhost:8080 with hot reload. Changes to Go and templ files are automatically detected and the server restarts.
How It Works
In web mode, irgo runs as a standard Go HTTP server. The same handlers and templates you write for mobile and desktop work identically in the browser.
// main.go (web/mobile entry point)//go:build !desktopfunc runDevServer() { r := app.NewRouter() mux := http.NewServeMux() mux.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static")))) mux.Handle("/", r.Handler()) fmt.Println("Dev server at http://localhost:8080") log.Fatal(http.ListenAndServe(":8080", mux))}Hot Reload Configuration
Hot reload is powered by air. The configuration is in .air.toml:
[build]cmd = "templ generate && npx tailwindcss -i ./static/css/input.css -o ./static/css/output.css --minify && go build -o ./tmp/main ."bin = "tmp/main serve"include_ext = ["go", "templ", "html", "css"]exclude_dir = ["tmp", "vendor", "node_modules"][misc]clean_on_exit = trueThis configuration runs templ generation and Tailwind CSS compilation on every file change, so you don't need separate watchers.
Production Deployment
For production web deployment, build a standard Go binary:
# Generate templatestempl generate# Build CSSnpx tailwindcss -i static/css/input.css -o static/css/output.css --minify# Build binarygo build -o myapp .# Run./myapp serveDocker Deployment
FROM golang:1.21-alpine AS builderWORKDIR /appCOPY go.mod go.sum ./RUN go mod downloadCOPY . .RUN go install github.com/a-h/templ/cmd/templ@latestRUN templ generateRUN CGO_ENABLED=0 go build -o myapp .FROM alpine:latestWORKDIR /appCOPY --from=builder /app/myapp .COPY --from=builder /app/static ./staticEXPOSE 8080CMD ["./myapp", "serve"]Next Steps
- Desktop Apps - Package as desktop application
- Mobile Apps - Build for iOS and Android
- Deployment - Deployment strategies
