Isolated learning atmosphere · v4.x
Nitro v3 in Practice: Build Ampyard
Most server tutorials hand you a to-do API, a weather card, or a chat room with no persistence. This one hands you a charging depot.
Ampyard is a fictional EV charging stop on the A1 corridor: eight bays, a queue, live charger telemetry, a session ledger, a depot clock, and an operator radio. You build it one real stage at a time, and every lesson embeds the actual app at that stage.
Why Nitro v3, and why now?#
Nitro v3 is the server engine Nuxt 5 is built on. It is also a standalone framework: file-based routes, web-standard handlers, cache, D1 (and an optional KV path), tasks, cron, WebSockets, OpenAPI, and a Vite plugin that builds the client and server together.
Nuxt 4.7 lets you opt into Nitro v3 behind a flag. That is useful, but it also hides the seams. Ampyard starts from the other direction: a Vite + Vue app with Nitro as the server, no Nuxt in the room. You see every route, every binding, and every deploy decision.
Nitro v3 is a release candidate. The API is stable enough to teach, but pin the version you build against (3.0.261103-rc in this series) and do not ship it to a business-critical depot yet.
What you will build#
Nine stages, one codebase:
- Foundation — Nitro + Vite + Vue Router SSR, the branded shell, and
/preview/:stage. Live now. - Routes — web-standard handlers, bay detail, middleware, and errors. Live now.
- Cache — a two-second snapshot cache with SWR and an honest
x-cacheheader. Live now. - Holds — D1-backed bay holds and a charging queue. Live now.
- Ledger — D1 sessions, drivers, and money that outlive a restart. Live now.
- Clock — tasks, cron, settlement, rollups, and the Nitro CLI. Live now.
- Live — SSE for the board and a WebSocket ops radio. Live now.
- Contract — OpenAPI for charger agents and Vitest tests. Live now.
- Ship — runtime mode, Cloudflare Workers, D1 (and optional KV), cron triggers, and a Durable Object. Live now.
The final app is /. The /preview/:stage route shows the app with only the features that exist at that point. The preview above is the real stage 9 app, not a video.
How this series works#
Each lesson follows the same shape:
What it is → Why you'd care → What we're building → Before/After → Do it yourself → Live stage → Gotchas → Recap.
The live stage is part of the lesson. It is a real iframe pointing at the deployed app. The blog reads NUXT_PUBLIC_AMPYARD_URL; the app reads the stage number. The code in the lesson is the code in apps/ampyard, so the preview and the source cannot drift.
Before you start#
- Node 22.22.3+ (the same floor Nuxt 4.7 uses).
pnpmand a terminal.- Vue 3 and TypeScript basics.
- A Cloudflare account for the final deploy. Local development only needs Node.
Nitro gives us the pieces the depot needs: routing, cache, KV, database, tasks, WebSockets, OpenAPI, and the Vite plugin.
Start here#
All nine stages are live. Start with The Ampyard Foundation, then Routes on Web Standards, Cache the Board, D1 Holds and the Queue, The D1 Ledger, The Depot Clock, Live: SSE + WebSocket, The Charger Contract, and Ship It.
The final depot is /.
Steps
- 1
The Ampyard Foundation: Nitro v3 + Vite + Vue
Nitro + Vite + Vue Router
- 2
Routes on Web Standards: Bays, Tariffs, and Honest Errors
defineHandler + Request/Response
- 3
Cache the Board: Two Seconds, One Honest Header
defineCachedHandler + SWR
- 4
D1 Holds and the Queue: Pick the Right Store
D1 holds + queue
- 5
The D1 Ledger: Sessions, Drivers, and Money
useDatabase + D1
- 6
The Depot Clock: Tasks, Cron, and runTask
Tasks + scheduledTasks
- 7
Live: SSE for the Board, WebSocket for the Radio
SSE + defineWebSocketHandler
- 8
The Charger Contract: OpenAPI and Vitest
OpenAPI + Vitest
- 9
Ship It: Runtime Mode, Cloudflare, and a Smoke Test
Build + deploy + runtime mode