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

main
mdx 181 lines 7.51 KB
Raw
1 ---
2 title: Websites
3 description: Deploy Vite, Astro, Next.js, vinext, Nuxt, React Router, SolidStart, SvelteKit, TanStack Start, Waku, Octane, Foldkit, Vocs, or any static build to Fly with first-class Website resources.
4 sidebar:
5 label: Overview
6 order: 1
7 ---
8
9 Alchemy deploys frontends to Fly with a family of `Fly.Website`
10 resources. Each one builds your project programmatically and
11 deploys it as a Node [Service](/fly/compute/services) on a Fly
12 [App](/fly/compute/apps) — a Machine listening on port 3000, plus
13 a shared IPv4 so `https://{app}.fly.dev` answers — with no
14 `fly.toml` and no adapter to put in the framework config. Your
15 framework's own config file (`vite.config.ts`, `astro.config.*`,
16 `nuxt.config.ts`, ...) loads natively; Alchemy layers its Node
17 container integration on top.
18
19 - [`Vite`](/fly/frontend/vite) — client-only Vite apps (React,
20 Vue, Solid SPAs, `index.html` multi-page sites); a tiny
21 static-file server serves the `vite build` output.
22 - [`Astro`](/fly/frontend/astro) — Astro sites, server-rendered
23 on Node or fully static; your `astro.config.*` loads natively.
24 - [`Nextjs`](/fly/frontend/nextjs) — Next.js as a long-running
25 Node process (`next build`, then `next({ dev: false })`). Not
26 OpenNext.
27 - [`Vinext`](/fly/frontend/vinext) — vinext (Next.js API on Vite)
28 as a long-running Node process (`vinext build`, then
29 `startProdServer`). Not the Cloudflare Worker path.
30 - [`Nuxt`](/fly/frontend/nuxt) — Nuxt apps through nitro's Node
31 server; your `nuxt.config.ts` loads natively. Do not set
32 `nitro.preset`.
33 - [`ReactRouter`](/fly/frontend/react-router) — React Router v8 in
34 framework mode, built through your own `vite build`.
35 - [`SolidStart`](/fly/frontend/solidstart) — SolidStart 2.x SSR;
36 Alchemy appends nitro's `node` preset to your `vite build`.
37 - [`SvelteKit`](/fly/frontend/sveltekit) — SvelteKit SSR plus
38 prerendered assets; the Node adapter is injected. Do not set
39 `kit.adapter`.
40 - [`TanStackStart`](/fly/frontend/tanstack-start) — TanStack Start
41 (React or Solid), built through your own `vite build`.
42 - [`Waku`](/fly/frontend/waku) — Waku (React Server Components)
43 on Node, with SSG pages served extensionless.
44 - [`Octane`](/fly/frontend/octane) — OctaneJS SSR. Alchemy wraps
45 native Node output; no hosting adapter is needed in `octane.config.ts`.
46 - [`Foldkit`](/fly/frontend/foldkit) — Foldkit SPA, SSR, and prerendered apps;
47 browser-only deep links fall back to `index.html`.
48 - [`Vocs`](/fly/frontend/vocs) — prerendered Vocs docs; extensionless
49 pages (`/about` → `about/index.html`).
50 - [`StaticSite`](/fly/frontend/static-site) — any build command's
51 output directory (Hugo, Zola, Eleventy).
52
53 Each resource creates a `Fly.App` when you omit `app`, a
54 `Fly.Service` on port 3000, and a `shared_v4`
55 [`IpAssignment`](/fly/networking) so `{app}.fly.dev` answers.
56 `domain` requests ACME via [`Certificate`](/fly/networking#use-your-own-hostname)
57 (existing DNS only for v1); `url` becomes `https://{domain}`.
58 The return is `{ url, app, service, ip, certificate }` —
59 everything except `url` is `undefined` under `alchemy dev`.
60
61 Shared props: `rootDir`, `memo`, `env` (Machine process
62 environment — not Worker bindings), `dev`, `domain`, `app`.
63 Builds are memoized by content-hashing the input files — an
64 unchanged project skips the build.
65
66 ## What's supported
67
68 | Framework | Resource | Guide |
69 | --- | --- | --- |
70 | React / Vue / Solid SPA | `Vite` | [Vite](/fly/frontend/vite) |
71 | TanStack Start (React & Solid) | `TanStackStart` | [TanStack Start](/fly/frontend/tanstack-start) |
72 | React Router | `ReactRouter` | [React Router](/fly/frontend/react-router) |
73 | SolidStart | `SolidStart` | [SolidStart](/fly/frontend/solidstart) |
74 | Astro | `Astro` | [Astro](/fly/frontend/astro) |
75 | Next.js | `Nextjs` | [Next.js](/fly/frontend/nextjs) |
76 | vinext | `Vinext` | [vinext](/fly/frontend/vinext) |
77 | Nuxt | `Nuxt` | [Nuxt](/fly/frontend/nuxt) |
78 | SvelteKit | `SvelteKit` | [SvelteKit](/fly/frontend/sveltekit) |
79 | Waku | `Waku` | [Waku](/fly/frontend/waku) |
80 | OctaneJS | `Octane` | [Octane](/fly/frontend/octane) |
81 | Foldkit | `Foldkit` | [Foldkit](/fly/frontend/foldkit) |
82 | Vocs | `Vocs` | [Vocs](/fly/frontend/vocs) |
83 | Zola, Hugo, or any static generator | `StaticSite` | [Static sites](/fly/frontend/static-site) |
84
85 See
86 [examples/fly-website-vite](https://github.com/alchemy-run/alchemy/tree/main/examples/fly-website-vite)
87 for a Vite SPA next to a Fly Service API.
88
89 ## How to choose
90
91 Use the resource named after your framework. `Astro`, `Nextjs`,
92 `Nuxt`, `ReactRouter`, `SolidStart`, `SvelteKit`,
93 `TanStackStart`, `Waku`, `Octane`, `Foldkit`, and `Vocs` each
94 drive that framework's programmatic build and know its output
95 layout, config surface, and dev server.
96
97 Use `Vite` when the whole deployable output is static assets — a
98 React, Vue, or Solid SPA, or an `index.html`-per-route multi-page
99 app. SSR frameworks that wrap Vite (`Astro`, `SvelteKit`,
100 `Octane`, …) have their own resources; `Vite` never starts a
101 framework server module.
102
103 Use `StaticSite` when the build is an arbitrary shell command
104 that emits a directory of files.
105
106 ## Environment variables
107
108 Top-level `env` is copied onto `process.env` before build and
109 dev, and onto the Machine at deploy. Client inlining is whatever
110 the framework already does (`VITE_*` for Vite). It is not Worker
111 bindings and not AWS `server.environment`.
112
113 ```typescript
114 const site = yield* Fly.Website.Vite("Web", {
115 env: {
116 VITE_API_URL: api.url,
117 },
118 });
119 ```
120
121 Server code reads `process.env`. Pair a site with
122 [Postgres](/fly/data/postgres) the same way you would any other
123 Service: put the connection string in `env`, or bind
124 `ConnectPostgres` on a sibling [Service](/fly/compute/services).
125
126 ## Local development
127
128 `alchemy dev` runs the framework's own dev server (native HMR)
129 instead of deploying. `site.url` is the local address and no Fly
130 App, Service, IP, or certificate is created. Wrap the site in
131 `Alchemy.remote()` to deploy the live path even during dev.
132
133 ## Custom domain
134
135 ```typescript
136 const site = yield* Fly.Website.Astro("Web", {
137 domain: "app.example.com",
138 });
139 ```
140
141 A hostname string makes Alchemy request ACME on the App; you point DNS
142 at the App yourself. `url` becomes `https://app.example.com`.
143
144 To have Alchemy publish the records, pass the DNS host as `dns`. The site
145 then publishes the ACME challenge `CNAME` and the `A`/`AAAA` records at the
146 App through that host:
147
148 ```typescript
149 const site = yield* Fly.Website.Astro("Web", {
150 domain: { name: "app.example.com", dns: Cloudflare.DNS.Adapter() },
151 });
152 ```
153
154 `AWS.Route53.Adapter()` and `Hetzner.DNS.Adapter()` work the same way. See
155 [DNS Adapters](/infrastructure-as-code/dns-adapters).
156
157 ## Where next
158
159 - [The Vite resource](/fly/frontend/vite) — assets-only SPA,
160 `assets.notFoundHandling`, env inlining.
161 - [The StaticSite resource](/fly/frontend/static-site) — build
162 commands, SPA/404 handling.
163 - Framework guides:
164 [Astro](/fly/frontend/astro),
165 [Next.js](/fly/frontend/nextjs),
166 [Nuxt](/fly/frontend/nuxt),
167 [React Router](/fly/frontend/react-router),
168 [SolidStart](/fly/frontend/solidstart),
169 [SvelteKit](/fly/frontend/sveltekit),
170 [TanStack Start](/fly/frontend/tanstack-start),
171 [Waku](/fly/frontend/waku),
172 [Octane](/fly/frontend/octane),
173 [Foldkit](/fly/frontend/foldkit),
174 [Vocs](/fly/frontend/vocs).
175 - [Services](/fly/compute/services) — the Node process these
176 resources deploy.
177 - [Postgres](/fly/data/postgres) — managed Postgres next to a
178 site.
179 - [`Vite` reference](/providers/fly/website/vite),
180 [`Astro` reference](/providers/fly/website/astro),
181 [`StaticSite` reference](/providers/fly/website/staticsite).