@devries-cameron20 / t3code Mirror · read-only
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
mdx 144 lines 3.93 KB
Raw
1 ---
2 title: Waku
3 description: Deploy Waku to Prisma Compute with Prisma.Website.Waku — React Server Components and static pages on Bun, with Waku's native dev server locally.
4 sidebar:
5 order: 13
6 ---
7
8 import PackageManagers from "../../../../components/PackageManagers.astro";
9
10 export const devDeps = "@alchemy.run/frontend-frameworks @vercel/nft";
11
12 `Prisma.Website.Waku` builds a [Waku](https://waku.gg) React Server
13 Components app with the shared Node target. Its RSC server, client
14 assets, and SSG pages run on **Bun in Prisma Compute** after a `tar.gz`
15 upload. There is no Docker image or registry.
16
17 ## Install
18
19 Install the build-time integration in your project; the resource loads
20 its `/waku` and `/waku/node` exports:
21
22 <PackageManagers dev={devDeps} />
23
24 ## Configure Waku
25
26 A fresh project needs no deployment config. If present,
27 `waku.config.ts` loads natively, including plugins in its `vite` field:
28
29 ```typescript
30 // waku.config.ts
31 import tailwindcss from "@tailwindcss/vite";
32 import { defineConfig } from "waku/config";
33
34 export default defineConfig({
35 basePath: "/",
36 vite: { plugins: [tailwindcss()] },
37 });
38 ```
39
40 Waku does not load a standalone `vite.config.ts`. Put Vite config in
41 `waku.config.ts`. Don't set `unstable_adapter`: the shared Node target
42 owns it and rejects a conflicting adapter.
43
44 The resource's `waku` bag overrides `srcDir`, `distDir`, or `basePath`
45 from the file:
46
47 ```typescript
48 export const Website = Prisma.Website.Waku("Website", {
49 waku: { basePath: "/docs/" },
50 });
51 ```
52
53 ## Declare the Website
54
55 ```typescript
56 // alchemy.run.ts
57 import * as Prisma from "@alchemy.run/prisma";
58
59 export const Website = Prisma.Website.Waku("Website");
60 ```
61
62 `rootDir` defaults to `"."`. A live deployment creates a database-less
63 Prisma project if `project` is omitted; pass an existing project to
64 share it with other apps.
65
66 ## Add it to the Stack
67
68 ```typescript
69 // alchemy.run.ts
70 import * as Alchemy from "alchemy";
71 import * as Effect from "effect/Effect";
72
73 export default Alchemy.Stack(
74 "MyWakuSite",
75 { providers: Prisma.providers(), state: Alchemy.localState() },
76 Effect.gen(function* () {
77 const site = yield* Website;
78 return { url: site.url };
79 }),
80 );
81 ```
82
83 Pages configured with `render: "static"` are generated at build time
84 and served at extensionless URLs such as `/about`. Dynamic pages and
85 API routes run in Compute. `site.url` is the live endpoint.
86
87 ## Add environment variables
88
89 ```diff lang="typescript"
90 export const Website = Prisma.Website.Waku("Website", {
91 + env: {
92 + GREETING: "Hello from Alchemy!",
93 + API_BASE: "https://api.example.com",
94 + },
95 });
96 ```
97
98 `env` accepts strings or `Redacted` values. It is applied before build
99 and dev, and passed to Compute. Client inlining follows the framework's
100 rules; do not expose secrets in public keys.
101
102 ## Read the environment in server code
103
104 ```typescript
105 // src/pages/index.tsx
106 export default async function HomePage() {
107 return <h1>{process.env.GREETING ?? "hello"}</h1>;
108 }
109
110 export const getConfig = async () => ({ render: "dynamic" }) as const;
111 ```
112
113 The RSC server runs on Bun. Server components and API routes can read
114 `process.env`; static pages capture those values during prerendering.
115
116 ## Local dev
117
118 `bun alchemy dev` runs Waku's own server with HMR instead of deploying.
119 The Website creates no Prisma resources. Opt into the live path with:
120
121 ```typescript
122 export const Website = Prisma.Website.Waku("Website").pipe(
123 Alchemy.remote(),
124 );
125 ```
126
127 ## Custom domain
128
129 ```typescript
130 const site = yield* Prisma.Website.Waku("Web", {
131 domain: "app.example.com",
132 });
133 ```
134
135 `domain` creates `Prisma.CustomDomain` and makes `site.url` the HTTPS
136 hostname.
137 Configure returned DNS records yourself and verify status before cutover;
138 see [Custom domains](/prisma/frontend/websites#custom-domains).
139
140 ## Where next
141
142 - [Waku API](/providers/prisma/website/waku).
143 - [Waku example](https://github.com/alchemy-run/alchemy/tree/main/examples/prisma-website-waku).
144 - [Websites](/prisma/frontend/websites) and [Compute apps](/prisma/compute/apps).