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

main
ts 77 lines 2.62 KB
Raw
1 import { frameworkSite, type FrameworkSiteProps } from "./FrameworkSite.ts";
2
3 /** The framework-integration package that drives the React Router build. */
4 export const REACT_ROUTER_FRAMEWORK_SPECIFIER = "@alchemy.run/frontend-frameworks/react-router";
5
6 /** The Node container deploy target for the React Router build. */
7 export const REACT_ROUTER_NODE_TARGET_SPECIFIER =
8 "@alchemy.run/frontend-frameworks/react-router/node";
9
10 export interface ReactRouterProps extends FrameworkSiteProps {}
11
12 /**
13 * Deploy a [React Router](https://reactrouter.com) v7 app (framework mode)
14 * to Cloud Run: the SSR server in a Cloud Run container, static assets baked into the image,
15 * served assets-first then the framework handler.
16 *
17 * The build runs through
18 * `@alchemy.run/frontend-frameworks/react-router` with the
19 * `@alchemy.run/frontend-frameworks/react-router/node` deploy target — both
20 * must be installed in your project, alongside `@react-router/dev`,
21 * `react-router`, and `vite`.
22 *
23 * Your `vite.config.ts` needs no adapter wiring. React Router's server
24 * build is a `ServerBuild` manifest rather than a request handler, so the
25 * integration wraps the manifest with `createRequestHandler` and packages
26 * the resulting fetch handler as a Node HTTP server on Cloud Run's `PORT` (8080).
27 *
28 * React Server Components (React Router's `unstable` RSC plugin) and
29 * multi-environment builds are not supported yet — the build fails with an
30 * actionable error when more than one server entry is emitted.
31 *
32 *
33 * ### Creating React Router Sites
34 * **Example:** Basic React Router App
35 * ```typescript
36 * const site = yield* GCP.Website.ReactRouter("Web", {
37 * rootDir: "./app",
38 * });
39 * ```
40 *
41 * **Example:** Warm Instance with More Memory
42 * ```typescript
43 * const site = yield* GCP.Website.ReactRouter("Web", {
44 * rootDir: "./app",
45 * scaling: { minInstanceCount: 1 },
46 * resources: { limits: { cpu: "1", memory: "1Gi" } },
47 * });
48 * ```
49 *
50 * ### Server Configuration
51 * **Example:** Process Environment
52 * ```typescript
53 * const site = yield* GCP.Website.ReactRouter("Web", {
54 * rootDir: "./app",
55 * env: {
56 * GREETING: "Hello from React Router on Cloud Run!",
57 * },
58 * });
59 * ```
60 *
61 * **Example:** Read An Environment Variable From A Loader
62 * ```typescript
63 * // app/routes/home.tsx
64 * export function loader() {
65 * return { greeting: process.env.GREETING ?? "Hello!" };
66 * }
67 * ```
68 *
69 * @resource
70 * @product Website
71 */
72 export const ReactRouter = (id: string, props: ReactRouterProps = {}) =>
73 frameworkSite(id, props, {
74 name: "ReactRouter",
75 framework: REACT_ROUTER_FRAMEWORK_SPECIFIER,
76 target: REACT_ROUTER_NODE_TARGET_SPECIFIER,
77 });