Skip to main content
Development mode is designed to give you the best developer experience with instant feedback and minimal configuration. When you run your Mizu app in development, it acts as a reverse proxy to your frontend dev server.

How Development Mode Works

In development, Mizu proxies requests to your frontend dev server (usually Vite, webpack-dev-server, or similar):
The flow:
  1. Browser requests http://localhost:3000/
  2. Mizu checks if the path starts with /api (or other ignore paths)
  3. If yes β†’ Handle with Go API routes
  4. If no β†’ Proxy to the frontend dev server
  5. Frontend dev server responds with the latest code

Enabling Development Mode

Automatic Detection

The simplest way is to use auto-detection:
Set the environment variable to enable development:

Explicit Development Mode

You can explicitly set development mode:
Or with options:

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

  1. You edit a React component
  2. Vite detects the file change
  3. Vite sends an update via WebSocket
  4. The browser receives the update
  5. Only the changed component re-renders
  6. Your app state is preserved
Mizu’s role:
  • 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 server
  • GET /assets/main.js β†’ Proxied to dev server
  • GET /src/App.tsx β†’ Proxied to dev server (during HMR)
WebSocket Connections:
  • ws://localhost:3000/ β†’ Proxied to ws://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: Important: If your frontend dev server runs on port 3000, change either the Mizu port or the frontend port to avoid 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:
Now /auth and /webhooks are handled by Go, not proxied.

Disable Ignore Paths

If you want to proxy everything except explicit routes:
Remember: middleware order matters! Routes defined before the frontend middleware take precedence.

CORS in Development

Mizu automatically adds CORS headers in development mode:
This allows your frontend dev server to make requests to the Mizu API without CORS issues. In production, these permissive CORS headers are NOT added. Use the CORS middleware for production CORS configuration.

Error Handling

When the dev server is not running or unreachable, Mizu shows a helpful error page:
The page automatically retries every 2 seconds, so once you start your dev server, the page loads.

Complete Development Setup

Here’s a complete example:

app/server/app.go

app/server/config.go

Running Development

Or use the Makefile:

Development Workflow

A typical development session:
  1. Start both servers
  2. Open browser
  3. Make frontend changes
    • Edit React/Vue/Svelte components
    • Changes appear instantly (HMR)
    • No refresh needed!
  4. Make backend changes
    • Edit Go files
    • Stop server (Ctrl+C)
    • Restart server
    • Or use air for auto-reload
  5. 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:
You’ll see logs like:

HMR Not Working

  1. Check WebSocket is connected
    • Open browser DevTools
    • Go to Network tab β†’ WS (WebSockets)
    • Should see a connection to ws://localhost:3000
  2. Check Vite config allows external connections
  3. Check CORS headers
    • Network tab should show Access-Control-Allow-Origin: *

Next Steps

Production Mode

Learn how production mode optimizes performance

Configuration

Explore all configuration options

Troubleshooting

Fix common development issues

API Integration

Best practices for calling backend APIs