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

main
mdx 148 lines 4 KB
Raw
1 ---
2 title: Octane
3 description: Deploy OctaneJS to Prisma Compute with Prisma.Website.Octane — the Node target on Bun, SSR plus client assets, and native Vite dev locally.
4 sidebar:
5 order: 14
6 ---
7
8 import PackageManagers from "../../../../components/PackageManagers.astro";
9
10 export const devDeps = "@alchemy.run/frontend-frameworks @vercel/nft";
11
12 `Prisma.Website.Octane` runs your [OctaneJS](https://octanejs.dev)
13 project's Vite build. Octane builds the client and SSR bundles; the
14 shared Node target wraps the fetch handler as an HTTP program. Both
15 outputs are uploaded as `tar.gz` and run on **Bun in Prisma Compute**,
16 not a Docker Node container.
17
18 ## Install
19
20 Install the build-time integration; the resource loads `/octane` and
21 `/octane/node` from your project:
22
23 <PackageManagers dev={devDeps} />
24
25 ## Configure Octane
26
27 Keep native compiler and route settings in `octane.config.ts`, without
28 an adapter:
29
30 ```typescript
31 // octane.config.ts
32 import { defineConfig, RenderRoute } from "@octanejs/vite-plugin";
33
34 export default defineConfig({
35 router: {
36 routes: [new RenderRoute({ path: "/", entry: ["App", "/src/App.tsx"] })],
37 },
38 });
39 ```
40
41 `Prisma.Website.Octane` selects hosting and automatically wraps Octane's
42 default native Node output as an HTTP server running on Bun in Compute.
43 The legacy Node marker adapter remains optional for existing projects.
44
45 ## Configure Vite
46
47 Put Vite plugins alongside Octane's plugin in `vite.config.ts`:
48
49 ```typescript
50 // vite.config.ts
51 import { octane } from "@octanejs/vite-plugin";
52 import tailwindcss from "@tailwindcss/vite";
53 import { defineConfig } from "vite";
54
55 export default defineConfig({
56 plugins: [octane(), tailwindcss()],
57 });
58 ```
59
60 ## Declare the Website
61
62 ```typescript
63 // alchemy.run.ts
64 import * as Prisma from "@alchemy.run/prisma";
65
66 export const Website = Prisma.Website.Octane("Website");
67 ```
68
69 `rootDir` defaults to `"."`. Omit `project` for a database-less project
70 created only on live deploy, or pass a project already in your Stack.
71
72 ## Add it to the Stack
73
74 ```typescript
75 // alchemy.run.ts
76 import * as Alchemy from "alchemy";
77 import * as Effect from "effect/Effect";
78
79 export default Alchemy.Stack(
80 "MyOctaneSite",
81 { providers: Prisma.providers(), state: Alchemy.localState() },
82 Effect.gen(function* () {
83 const site = yield* Website;
84 return { url: site.url };
85 }),
86 );
87 ```
88
89 `site.url` is the Compute endpoint on deploy and the local dev URL otherwise.
90
91 ## Add environment variables
92
93 ```diff lang="typescript"
94 export const Website = Prisma.Website.Octane("Website", {
95 + env: {
96 + GREETING: "Hello from Alchemy!",
97 + API_BASE: "https://api.example.com",
98 + },
99 });
100 ```
101
102 Strings or `Redacted` values are applied before build and dev, and
103 passed to Compute as process environment.
104
105 ## Read the environment in server code
106
107 ```typescript
108 // octane.config.ts
109 new ServerRoute({
110 path: "/api/greeting",
111 methods: ["GET"],
112 handler: async () => Response.json({
113 greeting: process.env.GREETING ?? "hello",
114 }),
115 });
116 ```
117
118 Import `ServerRoute` from `@octanejs/vite-plugin` when adding this
119 route. Middleware and route handlers run on Bun and read `process.env`.
120
121 ## Asset routing
122
123 Files in `dist/client` are served first without invoking the Octane
124 handler. Requests that miss the client assets go to Octane SSR. Both
125 paths run in Compute; static assets are not a separate CDN deployment.
126
127 ## Local dev
128
129 `bun alchemy dev` starts Octane's Vite server with its in-process SSR,
130 server routes, RPC, and HMR. The Website creates no Prisma resources.
131 Use `.pipe(Alchemy.remote())` to opt into live deployment during dev.
132
133 ## Custom domain
134
135 ```typescript
136 const site = yield* Prisma.Website.Octane("Web", {
137 domain: "app.example.com",
138 });
139 ```
140
141 Configure the returned DNS records yourself and verify status before
142 cutover; see [Custom domains](/prisma/frontend/websites#custom-domains).
143
144 ## Where next
145
146 - [Octane API](/providers/prisma/website/octane).
147 - [Octane example](https://github.com/alchemy-run/alchemy/tree/main/examples/prisma-website-octane).
148 - [Websites](/prisma/frontend/websites) and [Compute apps](/prisma/compute/apps).