How Development Mode Works
In development, Mizu proxies requests to your frontend dev server (usually Vite, webpack-dev-server, or similar):- Browser requests
http://localhost:3000/ - Mizu checks if the path starts with
/api(or other ignore paths) - If yes → Handle with Go API routes
- If no → Proxy to the frontend dev server
- Frontend dev server responds with the latest code
Enabling Development Mode
Automatic Detection
The simplest way is to use auto-detection:Explicit Development Mode
You can explicitly set development mode:Hot Module Replacement (HMR)
HMR is what makes modern frontend development so fast. When you save a file, the changes appear instantly in your browser without a full page reload.How HMR Works
- You edit a React component
- Vite detects the file change
- Vite sends an update via WebSocket
- The browser receives the update
- Only the changed component re-renders
- Your app state is preserved
- Proxies the WebSocket connection between browser and Vite
- Preserves all HMR functionality
- No configuration needed!
What Gets Proxied
Mizu proxies both HTTP and WebSocket connections: HTTP Requests:GET /→ Proxied to dev serverGET /assets/main.js→ Proxied to dev serverGET /src/App.tsx→ Proxied to dev server (during HMR)
ws://localhost:3000/→ Proxied tows://localhost:5173/- Used for HMR updates
- Vite’s HMR protocol passes through unchanged
Dev Server Configuration
Default Ports
Different dev servers use different default ports:| Framework | Tool | Default Port |
|---|---|---|
| React | Vite | 5173 |
| Vue | Vite | 5173 |
| Svelte | Vite | 5173 |
| Angular | Angular CLI | 4200 |
| Next.js | Next.js | 3000 (conflicts!) |
Configuring Dev Server URL
Match your frontend dev server port:Custom Dev Server Timeout
If your dev server is slow to respond:Disabling WebSocket Proxying
If you don’t need HMR (unusual):Ignore Paths
By default, these paths bypass the proxy and go to your Go handlers:/api- API routes/health- Health check/metrics- Metrics endpoint
Custom Ignore Paths
Add your own paths:/auth and /webhooks are handled by Go, not proxied.
Disable Ignore Paths
If you want to proxy everything except explicit routes:CORS in Development
Mizu automatically adds CORS headers in development mode:Error Handling
When the dev server is not running or unreachable, Mizu shows a helpful error page:Complete Development Setup
Here’s a complete example:app/server/app.go
app/server/config.go
Running Development
Development Workflow
A typical development session:-
Start both servers
-
Open browser
-
Make frontend changes
- Edit React/Vue/Svelte components
- Changes appear instantly (HMR)
- No refresh needed!
-
Make backend changes
- Edit Go files
- Stop server (Ctrl+C)
- Restart server
- Or use
airfor auto-reload
-
Test API integration
- Call APIs from frontend
- Check browser Network tab
- Check server logs
Debugging Tips
Check Dev Server is Running
Check Mizu is Proxying
Enable Debug Logging
Add the logger middleware to see all requests:HMR Not Working
-
Check WebSocket is connected
- Open browser DevTools
- Go to Network tab → WS (WebSockets)
- Should see a connection to
ws://localhost:3000
-
Check Vite config allows external connections
-
Check CORS headers
- Network tab should show
Access-Control-Allow-Origin: *
- Network tab should show