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

main
mdx 137 lines 3.79 KB
Raw
1 ---
2 title: Nuxt
3 description: Deploy Nuxt to Prisma Compute with Prisma.Website.Nuxt — Nitro's Node target running on Bun and Nuxt's own dev server locally.
4 sidebar:
5 order: 10
6 ---
7
8 import PackageManagers from "../../../../components/PackageManagers.astro";
9
10 export const devDeps = "@alchemy.run/frontend-frameworks @vercel/nft";
11
12 `Prisma.Website.Nuxt` builds [Nuxt](https://nuxt.com) through your
13 project's `@nuxt/kit` with Nitro's Node target. The server, client
14 assets, and prerendered pages are uploaded as `tar.gz` and run on
15 **Bun in Prisma Compute**. No Docker image or registry is involved.
16
17 ## Install
18
19 Install the build integration in your project; the resource loads its
20 `/nuxt` and `/nuxt/node` exports:
21
22 <PackageManagers dev={devDeps} />
23
24 ## Configure Nuxt
25
26 Your `nuxt.config.ts` loads natively, including modules and layers:
27
28 ```typescript
29 // nuxt.config.ts
30 export default defineNuxtConfig({
31 modules: ["@nuxtjs/tailwindcss"],
32 routeRules: { "/about": { prerender: true } },
33 });
34 ```
35
36 Don't set `nitro.preset`. The shared Node target owns the preset and
37 rejects foreign presets. That build target still runs on Bun on Prisma.
38
39 ## Declare the Website
40
41 ```typescript
42 // alchemy.run.ts
43 import * as Prisma from "@alchemy.run/prisma";
44
45 export const Website = Prisma.Website.Nuxt("Website");
46 ```
47
48 `rootDir` defaults to `"."`. Omit `project` to create a database-less
49 Prisma project on live deploy, or pass a project already in your Stack.
50
51 ## Add it to the Stack
52
53 ```typescript
54 // alchemy.run.ts
55 import * as Alchemy from "alchemy";
56 import * as Effect from "effect/Effect";
57
58 export default Alchemy.Stack(
59 "MyNuxtSite",
60 { providers: Prisma.providers(), state: Alchemy.localState() },
61 Effect.gen(function* () {
62 const site = yield* Website;
63 return { url: site.url };
64 }),
65 );
66 ```
67
68 `site.url` is the Compute endpoint on deploy and Nuxt's local URL in dev.
69
70 ## Add environment variables
71
72 ```diff lang="typescript"
73 export const Website = Prisma.Website.Nuxt("Website", {
74 + env: {
75 + GREETING: "Hello from Alchemy!",
76 + NUXT_PUBLIC_API_BASE: "https://api.example.com",
77 + },
78 });
79 ```
80
81 The environment is set before build and dev, and passed to Compute.
82 Matching `NUXT_*` keys override declared `runtimeConfig` values using
83 Nuxt's normal conventions. Public runtime config is visible to the
84 browser; do not put secrets there.
85
86 ## Read the environment in server code
87
88 ```typescript
89 // server/api/hello.ts
90 export default defineEventHandler(() => ({
91 greeting: process.env.GREETING ?? "hello",
92 }));
93 ```
94
95 Server routes and SSR run on Bun and can read `process.env`.
96
97 ## Prerendering
98
99 Override native config with the `nuxt` bag:
100
101 ```typescript
102 export const Website = Prisma.Website.Nuxt("Website", {
103 nuxt: {
104 routeRules: { "/about": { prerender: true } },
105 },
106 });
107 ```
108
109 Prerendered pages land in `.output/public` and are served as files
110 before the Nitro handler. They remain part of the Compute deployment,
111 not a separate CDN publication. Use `prerender` for build-time static
112 routes and Nitro `cache` rules for runtime caching; provider-specific
113 ISR behavior from Vercel or Netlify does not carry over to this target.
114
115 ## Local dev
116
117 `bun alchemy dev` starts Nuxt's native server with HMR and creates no
118 Prisma resources for the Website. Use `.pipe(Alchemy.remote())` to
119 opt into the live deployment during dev.
120
121 ## Custom domain
122
123 ```typescript
124 export const Website = Prisma.Website.Nuxt("Website", {
125 domain: "app.example.com",
126 });
127 ```
128
129 Configure the returned DNS records yourself and check provisioning
130 status before cutover. See
131 [Custom domains](/prisma/frontend/websites#custom-domains).
132
133 ## Where next
134
135 - [Nuxt API](/providers/prisma/website/nuxt).
136 - [Nuxt example](https://github.com/alchemy-run/alchemy/tree/main/examples/prisma-website-nuxt).
137 - [Websites](/prisma/frontend/websites), [Compute apps](/prisma/compute/apps), and [Setup](/prisma/setup).