@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.71 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 Railway: the SSR server plus client assets on one `Railway.Service`.
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 port 3000.
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 * During `alchemy dev` the site is React Router's own Vite dev server and
33 * no cloud resources are created. `Alchemy.remote()` opts back into the
34 * live Service path.
35 *
36 * ### Creating React Router Sites
37 * **Example:** Basic React Router App
38 * ```typescript
39 * const site = yield* Railway.Website.ReactRouter("Web", {
40 * rootDir: "./app",
41 * });
42 * ```
43 *
44 * **Example:** Custom Domain
45 * ```typescript
46 * const site = yield* Railway.Website.ReactRouter("Web", {
47 * rootDir: "./app",
48 * domain: "app.example.com",
49 * });
50 * ```
51 *
52 * ### Server Configuration
53 * **Example:** Process Environment
54 * ```typescript
55 * const site = yield* Railway.Website.ReactRouter("Web", {
56 * rootDir: "./app",
57 * env: {
58 * GREETING: "Hello from React Router on Railway!",
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));