Views Feature
Views feature
The views feature adds a React SPA powered by Vite. The frontend is embedded into the Go binary via embed.FS and served by the Echo server, with dev-mode hot-reload proxied to the Vite dev server.
What it provides
| File | Purpose |
|---|---|
internal/adapters/http/web/views.go |
SPA serving + Vite proxy middleware |
static/embed.go |
Go embed for built frontend assets |
views/package.json |
Frontend dependencies |
views/vite.config.js |
Vite dev server configuration |
views/index.html |
HTML entry point |
views/src/main.jsx |
React entry point |
views/src/App.jsx |
React application component |
views/src/App.css |
Application styles |
views/src/api.js |
API client module |
How serving works
- Development: Echo proxies
/requests to the Vite dev server (HMR enabled). - Production: Vite builds to
views/dist/, which is embedded viastatic/embed.goand served directly by Echo. - Toggle between modes with
views.enabledandviews.dev_serverin config.
Tech stack
| Library | Purpose | Documentation |
|---|---|---|
| React | UI component library | react.dev |
| Vite | Frontend build tool and dev server | vitejs.dev |
| Go embed | Embedded static file serving | pkg.go.dev/embed |
Learning resources
- React documentation — react.dev (learn, reference, tutorials)
- Vite getting started — vitejs.dev/guide
- Go embed documentation — pkg.go.dev/embed
- React + Vite tutorial — vitejs.dev/guide/#scaffolding-your-first-vite-project
- shadcn/ui — ui.shadcn.com (popular component library for React + Vite)
Notes
- The frontend source lives under
views/at the project root, not insideinternal/. - In development, Vite HMR provides instant hot module replacement — edit React components and see updates in real time.
- The Go embed directive reads from
static/dist/, which is where the built frontend assets are copied during deployment. - This feature adds zero Go dependencies — the
static/embed.gouses only the standard library.