@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 136 lines 3.99 KB
Raw
1 ---
2 title: Vinext
3 description: Deploy vinext to Fly with the shared Website API, native local development, and a platform-specific data cache.
4 sidebar:
5 order: 9.6
6 ---
7
8 import PackageManagers from "../../../../components/PackageManagers.astro";
9
10 export const devDeps = "@alchemy.run/frontend-frameworks";
11
12 `Fly.Website.Vinext` builds with the Vinext Vite API for production and runs native
13 `vinext dev` locally. The built app runs in a Fly Machine using vinext's production Node server.
14 Alchemy creates an App when `app` is omitted and deploys a Service containing
15 `dist/` and vinext's runtime dependencies.
16
17 ## Install
18
19 Keep `vinext`, `react`, `react-dom`, and `react-server-dom-webpack` in your
20 application dependencies, with `vite` and `@vitejs/plugin-rsc` for building.
21 Add the Alchemy integration:
22
23 <PackageManagers dev={devDeps} />
24
25 ## Configure vinext
26
27 ```typescript
28 // vite.config.ts
29 import { defineConfig } from "vite";
30 import vinext from "vinext";
31
32 export default defineConfig({
33 plugins: [vinext({ prerender: true })],
34 });
35 ```
36
37 Alchemy injects the target-specific data-cache adapter during deployment.
38 No Alchemy plugin is required in `vite.config.ts`; deployment settings belong on
39 `Website.Vinext`. Leave Cloudflare plugins and Worker entrypoints out of this application.
40
41 ## Declare the Website
42
43 ```typescript
44 // alchemy.run.ts
45 import * as Fly from "@alchemy.run/fly";
46
47 export const Website = Fly.Website.Vinext("Website", {
48 rootDir: ".",
49 });
50 ```
51
52 `rootDir`, `env`, `memo`, `assets`, `dev`, and `domain` use the same vocabulary
53 as the other Website constructors. Framework configuration stays in
54 `vite.config.ts` rather than a nested server configuration object.
55
56 ## Add it to the Stack
57
58 ```typescript
59 import * as Alchemy from "alchemy";
60 import * as Effect from "effect/Effect";
61
62 export default Alchemy.Stack(
63 "MyVinextSite",
64 { providers: Fly.providers(), state: Alchemy.localState() },
65 Effect.gen(function* () {
66 const site = yield* Website;
67 return { url: site.url };
68 }),
69 );
70 ```
71
72 Keep the local state available for subsequent deploys and teardown.
73
74 ## Add environment variables
75
76 ```typescript
77 export const Website = Fly.Website.Vinext("Website", {
78 env: { GREETING: "Hello from vinext on Fly!" },
79 });
80 ```
81
82 `env` is available during build, development, and production. Server code reads
83 `process.env`; public framework variables may be compiled into browser assets.
84 Keep secrets out of public keys and wrap credentials in `Redacted`.
85
86 ## Read the runtime environment
87
88 ```typescript
89 // app/api/hello/route.ts
90 export function GET(request: Request) {
91 const name = new URL(request.url).searchParams.get("name") ?? "world";
92 return Response.json({ name, greeting: process.env.GREETING ?? "hello" });
93 }
94 ```
95
96 Request-dependent route handlers read the production environment. A prerendered
97 page reflects its build-time inputs instead.
98
99 ## Configure the data cache
100
101 The default data cache is process-local. For shared, persistent ISR and
102 `"use cache"`, pass a `Fly.Redis` resource. Alchemy binds `REDIS_URL` as an App
103 secret. A separately declared Redis resource retains its own lifecycle in dev.
104
105 ```typescript
106 const redis = yield* Fly.Redis("Cache", { eviction: true });
107 const site = yield* Fly.Website.Vinext("Web", { redis });
108 ```
109
110 ## Local development
111
112 ```sh
113 bun alchemy dev
114 ```
115
116 The Website runs `vinext dev` with native HMR and creates no cloud resources.
117 Other resources declared in the Stack retain their own provider behavior.
118 Apply `.pipe(Alchemy.remote())` to the Website for a live deployment during dev.
119
120 ## Custom domains
121
122 ```typescript
123 const site = yield* Fly.Website.Vinext("Web", {
124 domain: "app.example.com",
125 });
126 ```
127
128 See [Website domains](/fly/frontend/websites) for platform-specific DNS and
129 certificate configuration.
130
131 ## Where next
132
133 - [vinext API reference](/providers/fly/website/vinext).
134 - [Runnable example](https://github.com/alchemy-run/alchemy/tree/main/examples/fly-website-vinext).
135 - [Website overview](/fly/frontend/websites).
136 - [vinext on Cloudflare](/cloudflare/frontend/vinext) and [Prisma](/prisma/frontend/vinext).