The best way to control Claude Code, Codex and more from any computer or phone

main
mdx 97 lines 2.43 KB
Raw
1 ---
2 title: Nuxt
3 description: Deploy a Nuxt app to Cloud Run with GCP.Website.Nuxt — the nitro Node server in a container, prerendered pages served as static files.
4 sidebar:
5 order: 13
6 ---
7
8 import PackageManagers from "../../../../components/PackageManagers.astro";
9
10 export const devDeps = "@alchemy.run/frontend-frameworks";
11
12 `GCP.Website.Nuxt` deploys a [Nuxt](https://nuxt.com) app to Cloud
13 Run. Nitro's Node server runs in the container. Prerendered pages and
14 static assets are served from the same image.
15
16 ## Install
17
18 The build integration ships separately. It only runs at deploy time,
19 so a dev dependency is enough:
20
21 <PackageManagers dev={devDeps} />
22
23 Docker has to be running when you deploy. The image is built on your
24 machine.
25
26 ## Deploy the site
27
28 ```typescript
29 // alchemy.run.ts
30 import * as Alchemy from "alchemy";
31 import * as GCP from "@alchemy.run/gcp";
32 import * as Effect from "effect/Effect";
33
34 export const Website = GCP.Website.Nuxt("Website");
35
36 export default Alchemy.Stack(
37 "MySite",
38 { providers: GCP.providers(), state: GCP.state() },
39 Effect.gen(function* () {
40 const site = yield* Website;
41 return { url: site.url };
42 }),
43 );
44 ```
45
46 Run `alchemy deploy`. `site.url` is the Cloud Run service URL.
47
48 ## Pass environment variables
49
50 ```diff lang="typescript"
51 // alchemy.run.ts
52 -export const Website = GCP.Website.Nuxt("Website");
53 +export const Website = GCP.Website.Nuxt("Website", {
54 + env: {
55 + GREETING: "Hello from Cloud Run!",
56 + },
57 +});
58 ```
59
60 Server routes read it from `process.env.GREETING`.
61
62 ## Configure Nuxt
63
64 Your `nuxt.config.ts` loads as-is. The `nuxt` prop merges extra config
65 over it for a single deploy:
66
67 ```typescript
68 export const Website = GCP.Website.Nuxt("Website", {
69 nuxt: { routeRules: { "/": { prerender: true } } },
70 });
71 ```
72
73 Don't set `nitro.preset`. Alchemy sets it.
74
75 ## Tune Cloud Run
76
77 ```typescript
78 export const Website = GCP.Website.Nuxt("Website", {
79 scaling: { minInstanceCount: 1 },
80 resources: { limits: { cpu: "1", memory: "1Gi" } },
81 });
82 ```
83
84 One warm instance means no cold start for the first visitor. See
85 [Websites](/gcp/frontend/websites#tune-cloud-run) for the other
86 settings.
87
88 ## Local development
89
90 `alchemy dev` runs the framework's dev server with hot reload and
91 creates nothing in the cloud. Wrap the site in `Alchemy.remote()` to
92 deploy it for real during dev.
93
94 ## Where next
95
96 - [Websites](/gcp/frontend/websites) — the settings every site shares.
97 - [Website reference](/providers/gcp/website#nuxt) — every prop.