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