Skip to content
Source
Sign inSign up
Open History to see the last commit

alchemy.run.ts

39 lines1.2 KB

1import * as Cloudflare from "@alchemy.run/cloudflare";
2import * as Alchemy from "alchemy";
3import * as Effect from "effect/Effect";
4​
5export default Alchemy.Stack(
6 "CloudflareWebsiteReactRouterExample",
7 {
8 providers: Cloudflare.providers(),
9 state: Cloudflare.state(),
10 },
11 Effect.gen(function* () {
12 // React Router's RSC build emits multiple server environments (`rsc`
13 // and `ssr`); `viteEnvironments` tells Alchemy how they assemble into
14 // one Worker: the `rsc` environment is the Worker entry, and the `ssr`
15 // environment's chunks are bundled alongside so cross-environment
16 // `loadModule` calls resolve in the deployed Worker.
17 const site = yield* Cloudflare.Website.Vite("Website", {
18 compatibility: {
19 date: "2026-08-31",
20 },
21 // Only hash the files that affect the build, so unchanged sources
22 // skip the Vite build (and the deploy) entirely.
23 memo: {
24 include: ["app/**", "react-router-vite/**", "public/**", "package.json", "vite.config.ts"],
25 },
26 env: {
27 GREETING: "Hello from React Router on Cloudflare!",
28 },
29 viteEnvironments: {
30 entry: "rsc",
31 children: ["ssr"],
32 },
33 });
34​
35 return {
36 url: site.url,
37 };
38 }),
39);