Skip to content

Nuxt

GCP.Website.Nuxt deploys a Nuxt app to Cloud Run. Nitro’s Node server runs in the container. Prerendered pages and static assets are served from the same image.

The build integration ships separately. It only runs at deploy time, so a dev dependency is enough:

Terminal window
pnpm add -D https://pkg.alchemy.run/@alchemy.run/frontend-frameworks/a870ed4

Docker has to be running when you deploy. The image is built on your machine.

alchemy.run.ts
import * as Alchemy from "alchemy";
import * as GCP from "@alchemy.run/gcp";
import * as Effect from "effect/Effect";
export const Website = GCP.Website.Nuxt("Website");
export default Alchemy.Stack(
"MySite",
{ providers: GCP.providers(), state: GCP.state() },
Effect.gen(function* () {
const site = yield* Website;
return { url: site.url };
}),
);

Run alchemy deploy. site.url is the Cloud Run service URL.

alchemy.run.ts
export const Website = GCP.Website.Nuxt("Website");
export const Website = GCP.Website.Nuxt("Website", {
env: {
GREETING: "Hello from Cloud Run!",
},
});

Server routes read it from process.env.GREETING.

Your nuxt.config.ts loads as-is. The nuxt prop merges extra config over it for a single deploy:

export const Website = GCP.Website.Nuxt("Website", {
nuxt: { routeRules: { "/": { prerender: true } } },
});

Don’t set nitro.preset. Alchemy sets it.

export const Website = GCP.Website.Nuxt("Website", {
scaling: { minInstanceCount: 1 },
resources: { limits: { cpu: "1", memory: "1Gi" } },
});

One warm instance means no cold start for the first visitor. See Websites for the other settings.

alchemy dev runs the framework’s dev server with hot reload and creates nothing in the cloud. Wrap the site in Alchemy.remote() to deploy it for real during dev.