| 1 | # packages/frontend-frameworks/fixtures/nuxt |
| 2 | |
| 3 | E2E fixture for `@alchemy.run/frontend-frameworks/nuxt`: a Nuxt 4 app built programmatically |
| 4 | through the project's `@nuxt/kit` with nitro's `cloudflare_module` preset — |
| 5 | wrangler-free (no `wrangler.json` is read or written). |
| 6 | |
| 7 | What it exercises: |
| 8 | |
| 9 | - **Native `nuxt.config.ts` loading** — `runtimeConfig.public.fixtureMarker` |
| 10 | and the `routeRules["/prerendered"].prerender` rule are user settings the |
| 11 | suite observes. |
| 12 | - **SSR + runtime contract** — the home page reads |
| 13 | `event.context.cloudflare.env.FIXTURE_SECRET` during SSR; `/api/hello` |
| 14 | checks `context.waitUntil`. |
| 15 | - **Prerendering** — `/prerendered` is written into `.output/public` at build |
| 16 | time and served by the assets layer. |
| 17 | - **Client hydration** — `/counter` flips a `data-hydrated` marker from |
| 18 | `onMounted` before interaction. |
| 19 | - **The nitro entry/exports seam** — `worker-entry.ts` is the configured |
| 20 | `main`: nitro bundles it as the worker entry, so its exports (nitro's |
| 21 | wrapped handler + the `Counter` SQLite Durable Object) are the worker's |
| 22 | exports; `/api/counter` drives the DO through the `COUNTER` namespace |
| 23 | binding. |
| 24 | |
| 25 | - **KV round-trip** — `/api/kv` puts/gets through |
| 26 | `event.context.cloudflare.env.FIXTURE_KV` (live: miniflare KV; dev: the |
| 27 | platform-proxy bridge). |
| 28 | |
| 29 | Modes: both the **live** suite (miniflare over `dist/build.json`) and the |
| 30 | **dev** suite run. Dev drives Nuxt's own dev server programmatically |
| 31 | (`loadNuxt({ dev: true })`); SSR runs in nitro's Node worker THREAD, where |
| 32 | the injected nitro plugin serves `event.context.cf` / |
| 33 | `event.context.waitUntil` / `event.context.cloudflare = { request, env, |
| 34 | context }` from cloudflare-runtime's platform proxy over HTTP (`{ url, |
| 35 | token }` via `runtimeConfig`) — wrangler-free, binding state shared with the |
| 36 | host workerd instance and preserved across dev rebuilds. The dev suite also |
| 37 | edits `server/api/hmr.ts` in place (restored in a `finally`) to prove a |
| 38 | rebuild + bridge reconnect. |
| 39 | |
| 40 | Dev-mode limitation: the Counter DO spec is live-only — the dev platform |
| 41 | proxy cannot host classes from the worker entry (the entry/exports seam only |
| 42 | exists in the production build), so dev serves Text + KV bindings. |
| 43 | |
| 44 | Dev port: 3111. |