| 1 | --- |
| 2 | title: Vocs |
| 3 | description: Deploy a Vocs docs site to Hetzner with Hetzner.Website.Vocs — prerendered HTML on a systemd unit, extensionless routes, and Vocs' own dev server under alchemy dev. |
| 4 | sidebar: |
| 5 | order: 10 |
| 6 | --- |
| 7 | |
| 8 | import { Code, Tabs, TabItem } from "@astrojs/starlight/components"; |
| 9 | |
| 10 | export const devDeps = "@alchemy.run/frontend-frameworks"; |
| 11 | |
| 12 | `Hetzner.Website.Vocs` deploys a [Vocs](https://vocs.dev) |
| 13 | documentation project to a Hetzner Cloud |
| 14 | [Server](/hetzner/compute/servers) as a systemd |
| 15 | [Service](/hetzner/compute/services) on port 3000. Vocs prerenders |
| 16 | static HTML; unmatched paths serve extensionless pages (`/about` → |
| 17 | `about/index.html`). The live URL is `http://{ipv4}:3000` — there is |
| 18 | no TLS on the Service. Your `vocs.config.*` loads natively — there |
| 19 | is no adapter to install. |
| 20 | |
| 21 | ## Install |
| 22 | |
| 23 | The build integration is not bundled with alchemy. Install |
| 24 | `@alchemy.run/frontend-frameworks`; the resource loads |
| 25 | `/vocs/node` from your project at deploy time. It is only used at |
| 26 | build time, so a dev dependency is enough: |
| 27 | |
| 28 | <Tabs syncKey="pkgManager"> |
| 29 | <TabItem label="bun" icon="bun"> |
| 30 | <Code code={`bun add -d ${devDeps}`} lang="sh" /> |
| 31 | </TabItem> |
| 32 | <TabItem label="npm" icon="npm"> |
| 33 | <Code code={`npm install -D ${devDeps}`} lang="sh" /> |
| 34 | </TabItem> |
| 35 | <TabItem label="pnpm" icon="pnpm"> |
| 36 | <Code code={`pnpm add -D ${devDeps}`} lang="sh" /> |
| 37 | </TabItem> |
| 38 | <TabItem label="yarn" icon="seti:yarn"> |
| 39 | <Code code={`yarn add -D ${devDeps}`} lang="sh" /> |
| 40 | </TabItem> |
| 41 | </Tabs> |
| 42 | |
| 43 | Your Vocs project already needs `vocs` installed. |
| 44 | |
| 45 | ## Configure Vocs |
| 46 | |
| 47 | Your `vocs.config.*` file loads natively — title, sidebar, and any |
| 48 | other Vocs options work exactly as they do outside Alchemy: |
| 49 | |
| 50 | ```typescript |
| 51 | // vocs.config.ts |
| 52 | import { defineConfig } from "vocs/config"; |
| 53 | |
| 54 | export default defineConfig({ |
| 55 | title: "Docs", |
| 56 | sidebar: [ |
| 57 | { text: "Home", link: "/" }, |
| 58 | { text: "Guide", link: "/guide" }, |
| 59 | ], |
| 60 | }); |
| 61 | ``` |
| 62 | |
| 63 | If `vocs.config.*` sets `outDir`, pass the same value on the |
| 64 | resource (default `"dist"`) so generated output stays outside the |
| 65 | rebuild hash: |
| 66 | |
| 67 | ```typescript |
| 68 | export const Website = Hetzner.Website.Vocs("Website", { |
| 69 | rootDir: "./docs", |
| 70 | outDir: "build", |
| 71 | }); |
| 72 | ``` |
| 73 | |
| 74 | ## Declare the Website |
| 75 | |
| 76 | Declare the site as a module-level const (rather than inline in the |
| 77 | Stack): |
| 78 | |
| 79 | ```typescript |
| 80 | // alchemy.run.ts |
| 81 | import * as Hetzner from "alchemy/Hetzner"; |
| 82 | |
| 83 | export const Website = Hetzner.Website.Vocs("Website", { |
| 84 | rootDir: "./docs", |
| 85 | }); |
| 86 | ``` |
| 87 | |
| 88 | Omit `server` to create a `cpx12` / `ubuntu-24.04` box in `fsn1`. |
| 89 | Pass an existing `Hetzner.Server` when several sites or APIs should |
| 90 | share one VM: |
| 91 | |
| 92 | ```typescript |
| 93 | export const Box = Hetzner.Server("box", { |
| 94 | serverType: "cpx12", |
| 95 | image: "ubuntu-24.04", |
| 96 | location: "fsn1", |
| 97 | }); |
| 98 | |
| 99 | export const Website = Hetzner.Website.Vocs("Website", { |
| 100 | rootDir: "./docs", |
| 101 | server: Box, |
| 102 | }); |
| 103 | ``` |
| 104 | |
| 105 | ## Add it to the Stack |
| 106 | |
| 107 | Yield the site from your Stack and return its URL: |
| 108 | |
| 109 | ```typescript |
| 110 | // alchemy.run.ts |
| 111 | import * as Alchemy from "alchemy"; |
| 112 | import * as Effect from "effect/Effect"; |
| 113 | |
| 114 | export default Alchemy.Stack( |
| 115 | "MyVocsSite", |
| 116 | { |
| 117 | providers: Hetzner.providers(), |
| 118 | state: Alchemy.localState(), |
| 119 | }, |
| 120 | Effect.gen(function* () { |
| 121 | const site = yield* Website; |
| 122 | return { url: site.url }; |
| 123 | }), |
| 124 | ); |
| 125 | ``` |
| 126 | |
| 127 | The live URL is `http://{ipv4}:3000`. The unit listens on port 3000 |
| 128 | and answers `GET /health` (`deployUnit` curls that path whenever |
| 129 | `PORT` is set). `site.server` and `site.service` are set on deploy. |
| 130 | |
| 131 | ## Add environment variables |
| 132 | |
| 133 | Top-level `env` is copied onto `process.env` before build and |
| 134 | `alchemy dev`, and onto the systemd unit at deploy: |
| 135 | |
| 136 | ```diff lang="typescript" |
| 137 | // alchemy.run.ts |
| 138 | export const Website = Hetzner.Website.Vocs("Website", { |
| 139 | rootDir: "./docs", |
| 140 | + env: { |
| 141 | + DOCS_TITLE: "Hello from Alchemy!", |
| 142 | + }, |
| 143 | }); |
| 144 | ``` |
| 145 | |
| 146 | These are process environment variables, not Worker bindings. |
| 147 | |
| 148 | ## Read the environment |
| 149 | |
| 150 | Vocs prerenders at build time, so page content that reads |
| 151 | `process.env` is baked into the HTML. The same values are set on |
| 152 | the hosted Node process; there is no request-time Vocs server. |
| 153 | |
| 154 | ```typescript |
| 155 | const title = process.env.DOCS_TITLE ?? "Docs"; |
| 156 | ``` |
| 157 | |
| 158 | ## Local development |
| 159 | |
| 160 | `alchemy dev` runs Vocs' own dev server (native HMR) instead of |
| 161 | deploying; `site.url` is the local address and no Hetzner resources |
| 162 | are created (`server` and `service` are `undefined`). Wrap the site |
| 163 | in `Alchemy.remote()` to deploy the live Server and Service even |
| 164 | during dev: |
| 165 | |
| 166 | ```typescript |
| 167 | export const Website = Hetzner.Website.Vocs("Website", { |
| 168 | rootDir: "./docs", |
| 169 | }).pipe(Alchemy.remote()); |
| 170 | ``` |
| 171 | |
| 172 | ## Custom domain |
| 173 | |
| 174 | `domain` requires an existing Hetzner DNS [Zone](/hetzner/networking/dns) |
| 175 | (`zone`). Alchemy creates an A [RecordSet](/hetzner/networking/dns) |
| 176 | pointing at the Server's public IPv4; `url` becomes |
| 177 | `http://{domain}:3000`. v1 does not provision a Zone — omitting |
| 178 | `zone` when `domain` is set fails: |
| 179 | |
| 180 | ```typescript |
| 181 | export const Dns = Hetzner.Zone("dns", { |
| 182 | name: "example.com", |
| 183 | }); |
| 184 | |
| 185 | export const Website = Hetzner.Website.Vocs("Website", { |
| 186 | rootDir: "./docs", |
| 187 | domain: "docs.example.com", |
| 188 | zone: Dns, |
| 189 | }); |
| 190 | ``` |
| 191 | |
| 192 | There is no TLS on the Service. |
| 193 | |
| 194 | ## Where next |
| 195 | |
| 196 | - [`Vocs` reference](/providers/hetzner/website/vocs) — every prop |
| 197 | and attribute |
| 198 | - [Servers](/hetzner/compute/servers) and |
| 199 | [Services](/hetzner/compute/services) — the VM and systemd unit |
| 200 | - [Zones & records](/hetzner/networking/dns) — the Zone `domain` |
| 201 | requires |
| 202 | - [Hetzner](/hetzner) — the Hetzner provider hub |