Overview
Static file serving in Mizu supports multiple file sources:Serving from a Local Directory
The simplest approach is serving files from a folder on disk:Directory Structure Example
Serving Embedded Files
For production deployments, embed static files directly into your Go binary using theembed package. This creates a single executable with no external file dependencies.
Understanding embed.FS
The//go:embed directive includes files at compile time:
The
embed package preserves directory structure. Use fs.Sub() to remove the root directory prefix when serving.SPA (Single Page Application) Support
Single page applications require all routes to returnindex.html so the frontend router can handle navigation.
Caching
Configure caching based on file types:Development vs Production
- Single binary deployment
- No missing file issues
- Faster startup (files already in memory)
- Immutable content (great for containers)
Summary
Next steps
Frontend Integration
Serve React, Vue, and other SPAs.
Deployment
Production deployment strategies.