Docs Cloud
Docs Cloud is the hosted layer around @farming-labs/docs. Your repo stays the source of truth,
your app still owns the runtime, and Cloud adds managed previews, publish workflows, analytics, AI,
search, and agent operations on top.
The first integration surface is the Cloud preview flow:
- create a Docs Cloud API key
- store the key in an environment variable
- add a serializable
cloudblock todocs.config.ts - sync that config into
docs.json - request a hosted preview
Cloud access
Docs Cloud is rolling out gradually. If your workspace does not have access yet, join the Cloud waitlist. Once access is enabled, create the API key from your Docs Cloud project settings.
Create An API Key
In Docs Cloud, open your workspace, choose the docs project, then create a project API key from the project settings. For previews, the key needs access to read the project and request previews.
Copy the key once and put it in your local environment:
DOCS_CLOUD_API_KEY=docs_cloud_...Use the same environment variable name as a CI secret when previews should run from GitHub Actions or another build system.
Do not commit secrets
Keep the raw API key in .env.local, your shell, or CI secrets. docs.config.ts should only
name the environment variable, and docs.json should only contain that environment variable name.
Configure docs.config.ts
Add the cloud block to your docs config:
import { defineDocs } from "@farming-labs/docs";
export default defineDocs({
entry: "docs",
cloud: {
apiKey: { env: "DOCS_CLOUD_API_KEY" },
preview: { enabled: true },
publish: { mode: "draft-pr", baseBranch: "main" },
},
});cloud.apiKey.env defaults to DOCS_CLOUD_API_KEY, but writing it explicitly makes the contract
clear for teammates and CI.
publish.mode is the default Cloud should use when generated docs changes need to go back to Git:
| Mode | Meaning |
|---|---|
"draft-pr" | Create a draft pull request targeting publish.baseBranch |
"direct-commit" | Commit directly to publish.baseBranch for trusted automation |
Sync docs.json
docs.json is the serializable project contract that Docs Cloud reads. It mirrors safe project
metadata from docs.config.ts; it does not store API key values.
Run:
pnpm exec docs cloud syncThis creates or updates docs.json:
{
"$schema": "https://docs.farming-labs.dev/schema/docs.json",
"version": 1,
"docs": {
"mode": "framework",
"runtime": "nextjs",
"root": "."
},
"content": {
"docsRoot": "docs"
},
"cloud": {
"apiKey": {
"env": "DOCS_CLOUD_API_KEY"
},
"preview": {
"enabled": true
},
"publish": {
"mode": "draft-pr",
"baseBranch": "main"
}
}
}Commit docs.json when you want the Cloud contract to be reviewed with the repo. The file is safe
to commit because it contains only configuration and environment variable names.
The generated cloud block intentionally omits enabled. The block itself opts the project into
Cloud-aware CLI flows; set "enabled": false only when you need to disable Cloud operations while
keeping the rest of the contract in place.
Request A Preview
Use docs preview from the project root:
pnpm exec docs previewdocs preview does three things:
- syncs
docs.config.tsintodocs.json - validates the configured API key with Docs Cloud
- requests a hosted preview deployment
The explicit Cloud command is equivalent:
pnpm exec docs cloud previewUse JSON output when another tool or CI job needs to read the preview URL:
pnpm exec docs preview --jsonUseful Options
| Command | Use it when |
|---|---|
pnpm exec docs cloud sync | You only want to update docs.json |
pnpm exec docs preview | You want to sync, validate the key, and preview |
pnpm exec docs cloud preview | You prefer the explicit Cloud namespace |
pnpm exec docs preview --json | CI or automation needs machine-readable output |
pnpm exec docs preview --config <path> | Your config file is outside the project root |
pnpm exec docs preview --api-base-url <url> | You are testing a staging or self-hosted Cloud API |
--api-key <key> also exists for local testing, but prefer cloud.apiKey.env plus an environment
variable so the key does not end up in shell history, logs, or docs.
Troubleshooting
Missing API key
If the CLI says the Docs Cloud API key is missing, set the env var named by cloud.apiKey.env:
export DOCS_CLOUD_API_KEY=docs_cloud_...or add it to .env.local.
Preview disabled
If cloud.preview.enabled is false, docs preview stops before making a hosted preview request.
Set it back to true or remove the override.
Wrong Cloud host
For staging or self-hosted testing, pass:
pnpm exec docs preview --api-base-url https://cloud.example.comYou can also set DOCS_CLOUD_API_URL in the environment.
Related Docs
- docs.json explains the repo-level contract that Cloud reads.
- Configuration lists the
cloudconfig fields. - CLI covers the full command surface.
- Cloud landing page explains the managed product direction and waitlist.
How is this guide?