Skip to content

Vocs

Source: src/Cloudflare/Website/Vocs.ts

A Cloudflare Worker deployed from a Vocs documentation project.

Vocs’ vocs.config.* loads natively. Alchemy runs Vocs’ Waku/RSC build, deploys its server environments as a Worker, and publishes the client and prerendered output as static assets. No Vite or Wrangler config is required.

Requires @alchemy.run/frontend-frameworks, vocs, and Vocs’ Waku peer dependencies in the project.

Input files are content-hashed (respecting .gitignore by default), so an unchanged project skips its build and deployment. Vocs’ server runtime uses Node APIs, so nodejs_compat is included in the Worker’s compatibility flags automatically.

A single resource builds the documentation project and deploys its server runtime, prerendered pages, generated files, and public assets.

const docs = yield* Cloudflare.Website.Vocs("Docs", {
rootDir: "./docs",
});

Pass Cloudflare resources through env like any other Worker. Server-side Vocs and MDX code can access them from cloudflare:workers.

const searchCache = yield* Cloudflare.KV.Namespace("SearchCache");
const docs = yield* Cloudflare.Website.Vocs("Docs", {
rootDir: "./docs",
env: {
SEARCH_CACHE: searchCache,
},
});

Vocs configuration continues to own the output directory. When vocs.config.* changes outDir, mirror that value on the resource so the generated directory is excluded from the rebuild hash and read correctly.

// vocs.config.ts: defineConfig({ outDir: "build" })
const docs = yield* Cloudflare.Website.Vocs("Docs", {
rootDir: "./docs",
outDir: "build",
});

Use memo to narrow the files that trigger a rebuild in large projects.

const docs = yield* Cloudflare.Website.Vocs("Docs", {
rootDir: "./docs",
memo: {
include: ["src/**", "public/**", "vocs.config.ts", "package.json"],
},
});

Calling Vocs without arguments returns a constructor for declaring the deployed Worker as a named class.

class Docs extends Cloudflare.Website.Vocs<Docs>()("Docs", {
rootDir: "./docs",
}) {}
const docs = yield* Docs;