The best way to control Claude Code, Codex and more from any computer or phone
| 1 | # @alchemy.run/hetzner |
| 2 | |
| 3 | Hetzner Cloud for [Alchemy](https://alchemy.run). Declare Servers, volumes, networks, firewalls, load balancers, and DNS, and run Effect programs on those Servers, all in one TypeScript program. |
| 4 | |
| 5 | ```sh |
| 6 | npm install alchemy @alchemy.run/hetzner effect |
| 7 | ``` |
| 8 | |
| 9 | A Server with a mounted volume, and a Service that runs on it: |
| 10 | |
| 11 | ```typescript |
| 12 | // src/api.ts |
| 13 | import * as Hetzner from "@alchemy.run/hetzner"; |
| 14 | import * as Effect from "effect/Effect"; |
| 15 | import * as HttpServerResponse from "effect/http/HttpServerResponse"; |
| 16 | |
| 17 | export const Box = Hetzner.Server("Box", { |
| 18 | serverType: "cpx12", |
| 19 | image: "ubuntu-24.04", |
| 20 | location: "nbg1", |
| 21 | }); |
| 22 | |
| 23 | export const Data = Hetzner.Volume("Data", { |
| 24 | size: 10, |
| 25 | format: "ext4", |
| 26 | location: "nbg1", |
| 27 | }); |
| 28 | |
| 29 | export default class Api extends Hetzner.Service<Api>()( |
| 30 | "Api", |
| 31 | { server: Box, main: import.meta.url, port: 3000 }, |
| 32 | Effect.gen(function* () { |
| 33 | const mount = yield* Hetzner.MountVolume(yield* Data, { path: "/data" }); |
| 34 | |
| 35 | return { |
| 36 | fetch: HttpServerResponse.json({ volume: mount.path }), |
| 37 | }; |
| 38 | }).pipe(Effect.provide(Hetzner.MountVolumeLive)), |
| 39 | ) {} |
| 40 | ``` |
| 41 | |
| 42 | ```typescript |
| 43 | // alchemy.run.ts |
| 44 | import * as Alchemy from "alchemy"; |
| 45 | import * as Hetzner from "@alchemy.run/hetzner"; |
| 46 | import * as Effect from "effect/Effect"; |
| 47 | import Api from "./src/api.ts"; |
| 48 | |
| 49 | export default Alchemy.Stack( |
| 50 | "MyApp", |
| 51 | { |
| 52 | providers: Hetzner.providers(), |
| 53 | state: Alchemy.localState(), |
| 54 | }, |
| 55 | Effect.gen(function* () { |
| 56 | const api = yield* Api; |
| 57 | return { url: api.url }; |
| 58 | }), |
| 59 | ); |
| 60 | ``` |
| 61 | |
| 62 | `alchemy deploy` creates the Server and volume, copies the bundled program over SSH, and runs it as a systemd unit. |
| 63 | |
| 64 | ## Learn more |
| 65 | |
| 66 | - [Hetzner on alchemy.run](https://alchemy.run/hetzner) |
| 67 | - [Setup](https://alchemy.run/hetzner/setup) |
| 68 | - [Tutorial](https://alchemy.run/hetzner/tutorial/part-1) |
| 69 | - [API reference](https://alchemy.run/providers) |