Deploy
Docs Cloud deploy creates a hosted preview for a connected docs project. The repo remains the source
of truth. The CLI syncs the serializable Cloud config into docs.json, validates the project API
key, then asks Docs Cloud to create or update the preview.
Requirements
- Docs Cloud access for the workspace
- a Docs Cloud project API key
DOCS_CLOUD_API_KEYavailable in your shell,.env.local, or CI secrets- a
cloudblock indocs.config.ts - a committed
docs.jsonwhen the repo contract should be reviewed in Git
Do not commit secrets
Keep the raw API key in .env.local, your shell, or CI secrets. docs.config.ts should reference
the environment variable name, and docs.json should only contain that environment variable name.
Configure Cloud
import { defineDocs } from "@farming-labs/docs";
export default defineDocs({
entry: "docs",
cloud: {
apiKey: { env: "DOCS_CLOUD_API_KEY" },
deploy: { enabled: true },
publish: { mode: "draft-pr", baseBranch: "main" },
},
});cloud.apiKey.env defaults to DOCS_CLOUD_API_KEY. Writing it explicitly makes the contract easier
to review in CI and pull requests.
Sync docs.json
docs.json is the JSON contract that Docs Cloud reads. It mirrors safe Cloud settings from
docs.config.ts; it does not store API key values.
pnpm dlx @farming-labs/docs cloud syncExample output:
{
"$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"
},
"deploy": {
"enabled": true
},
"publish": {
"mode": "draft-pr",
"baseBranch": "main"
}
}
}The generated cloud block intentionally omits enabled. The presence of the block opts the
project into Cloud-aware CLI flows. Set "enabled": false only when the repo should keep the local
contract but disable Cloud operations.
Deploy A Preview
Set the key, then run the deploy command from the project root:
export DOCS_CLOUD_API_KEY=fl_key_...
pnpm dlx @farming-labs/docs deploydocs deploy performs the same sync step before requesting the preview:
- read
docs.config.ts - write or update
docs.json - validate the Docs Cloud API key
- request a hosted preview deployment
The explicit Cloud command is equivalent:
pnpm dlx @farming-labs/docs cloud deployCheck Cloud Setup
Run a read-only health check before deploying or debugging Ask AI:
pnpm dlx @farming-labs/docs cloud checkThe check validates docs.config.ts, docs.json freshness, the hosted Docs Cloud API target,
cloud.apiKey.env, the Docs Cloud API key, required deploy scopes, analytics project envs,
the public docs origin used for browser CORS, ai.provider: "docs-cloud" direct or proxied
knowledge endpoint wiring, and browser CORS preflight for Cloud analytics/Ask AI. Use --json in CI or
--no-network when you only want local config checks.
Scope the report when you only want one integration area:
pnpm dlx @farming-labs/docs cloud check --analytics
pnpm dlx @farming-labs/docs cloud check --ask-ai
pnpm dlx @farming-labs/docs cloud check --deploy--ask-ai checks the Docs Cloud provider path end to end. Direct browser mode needs
PUBLIC_DOCS_CLOUD_PROJECT_ID plus PUBLIC_DOCS_CLOUD_API_KEY or another browser-safe
cloud.apiKey.env; Next.js projects can use the equivalent NEXT_PUBLIC_* names. The check also
sends a browser-style CORS preflight to the hosted knowledge endpoint. If only the server-side
project id and API key are available, the report marks the local docs API route as the proxy path and
skips browser CORS for Ask AI because the browser only talks to the same-origin docs app.
Example focused report:
Docs Cloud check
api https://api.farming-labs.dev
scope analytics
ok config Loaded docs.config.ts
warn docs.json docs.json is missing. Run docs cloud sync to materialize cloud config.
ok cloud.apiBaseUrl Using the hosted Docs Cloud API at https://api.farming-labs.dev.
ok docs.siteOrigin Public docs origin is https://docs.example.com.
ok cloud.enabled Docs Cloud is enabled.
ok analytics.runtime Runtime analytics is not disabled.
ok analytics.cloud Docs Cloud analytics is enabled in cloud.analytics.
ok project.env Docs Cloud project id is present in PUBLIC_DOCS_CLOUD_PROJECT_ID.
ok cors.analytics Analytics CORS allows https://docs.example.com.
ok Docs Cloud check passed with 1 warning.Use JSON output when CI or another tool needs the preview URL:
pnpm dlx @farming-labs/docs deploy --jsonCommands
| Command | Use it when |
|---|---|
pnpm dlx @farming-labs/docs cloud sync | You only want to update docs.json |
pnpm dlx @farming-labs/docs cloud check | You want to validate config, hosted API access, analytics envs, API key scopes, CORS, and Ask AI wiring without deploying |
pnpm dlx @farming-labs/docs cloud check --analytics | You only want to validate Docs Cloud analytics wiring and analytics CORS |
pnpm dlx @farming-labs/docs cloud check --ask-ai | You only want to validate Docs Cloud Ask AI endpoint wiring and Ask AI CORS |
pnpm dlx @farming-labs/docs cloud check --deploy | You only want to validate deploy flags, API key presence, and deploy scopes |
pnpm dlx @farming-labs/docs cloud check --json | CI or automation needs the full check result as JSON |
pnpm dlx @farming-labs/docs cloud check --no-network | You only want local config, env, and docs.json checks |
pnpm dlx @farming-labs/docs cloud check --api-key-env <name> | The deploy key lives in a custom env var |
pnpm dlx @farming-labs/docs deploy | You want to sync, validate the key, and request a preview |
pnpm dlx @farming-labs/docs cloud deploy | You prefer the explicit Cloud namespace |
pnpm dlx @farming-labs/docs deploy --json | CI needs machine-readable output |
pnpm dlx @farming-labs/docs deploy --config <path> | The docs config file is outside the project root |
pnpm dlx @farming-labs/docs deploy --api-base-url <url> | You are testing a staging or self-hosted Cloud API |
--api-key <key> is available for local testing. Prefer cloud.apiKey.env plus an environment
variable for normal use so the key does not end up in shell history or logs.
Publish Mode
cloud.publish controls what Docs Cloud should do when generated docs changes need to go back to
Git:
| Mode | Behavior |
|---|---|
"draft-pr" | Create a draft pull request targeting publish.baseBranch |
"direct-commit" | Commit directly to publish.baseBranch |
Use draft-pr for normal team workflows. Reserve direct-commit for trusted automation where the
Cloud project owns the branch policy.
Troubleshooting
Missing API key
Set the environment variable named by cloud.apiKey.env:
export DOCS_CLOUD_API_KEY=fl_key_...or add it to .env.local.
Deploy disabled
If cloud.deploy.enabled is false, docs deploy stops before requesting a hosted preview. Set it
back to true or remove the override.
Browser CORS blocked
Make sure the public docs URL is set in one of the places the check can read:
NEXT_PUBLIC_BASE_URL, NEXT_PUBLIC_SITE_URL, SITE_URL, site.url, sitemap.baseUrl,
llmsTxt.baseUrl, or robots.baseUrl.
For the hosted Docs Cloud API, you do not need to set a Docs Cloud API URL. If you are self-hosting the API, allow the same public docs origin in the API service CORS config.
Wrong Cloud host
For staging or self-hosted testing, pass:
pnpm dlx @farming-labs/docs deploy --api-base-url https://cloud.example.comDeploy a Docs Cloud preview from docs.config.ts, docs.json, and a project API key
How is this guide?