Docs commands
Learn about the Fern CLI docs commands.
These commands build, preview, and publish a Fern documentation site, and validate the MDX pages and links behind it. Creating a docs project with fern init --docs and validating docs.yml with fern check are general commands, and SDK commands generate client libraries from the same API definition your docs render. Each docs command accepts the global options.
Detailed command documentation
fern generate --docs
Use fern generate --docs to create a documentation site for your API.
instance
Use --instance to specify which instance URL in your docs.yml to generate documentation for.
preview
Use --preview to preview updates to your documentation before publishing changes to your production site.
id
Use --id with --preview to create a stable, named preview link. The preview URL follows the format {org}-preview-{id}.docs.buildwithfern.com, so rerunning with the same --id updates the existing preview in place rather than creating a new one.
This is useful in CI workflows where you want one preview URL per pull request. See Preview changes for details.
force
When reusing an --id that already exists, Fern prompts you to confirm the overwrite. Use --force to skip the confirmation. This is detected automatically in GitHub Actions, but is needed for other CI environments like Azure Pipelines.
fern docs dev
Use fern docs dev to run a local development server to preview your docs.
Windows: enable long path support
On Windows, fern docs dev requires long path support to be enabled.
To enable long path support, run the following command in an elevated PowerShell prompt, then restart your terminal:
If you can’t enable long path support, use Windows Subsystem for Linux (WSL) to run fern docs dev in a Linux environment instead.
port
Use --port <port-number> to specify the port the docs preview will be run on.
fern docs diff
Use fern docs diff to generate visual diffs between your preview deployment and production docs. This command is intended for use in GitHub Actions. It captures screenshots of both versions and creates side-by-side comparison images.
Pass the preview URL from fern generate --docs --preview and one or more MDX file paths. Diff images are saved to .fern/diff by default.
output
Use --output to specify a custom directory for diff images.
fern docs preview list
Use fern docs preview list to list all preview deployments for your organization.
limit
Use --limit to specify the number of preview deployments to display per page.
page
Use --page to specify which page of results to display.
fern docs preview delete
Use fern docs preview delete to delete a preview deployment generated with fern generate --docs --preview. Pass the full preview URL, or use --id to delete by the identifier used during generation.
id
Use --id to delete a preview deployment by the identifier used during generation instead of the full preview URL.
fern docs md check
Use fern docs md check to validate MDX syntax across all documentation pages referenced in your navigation configuration, including docs.yml, versioned configuration files, and product-specific YAML files.
The command parses each MDX file and reports syntax errors with file paths and line:column numbers. The command accounts for frontmatter offsets, so reported line numbers correspond to the actual lines in your file.
When all files are valid, you’ll see a success message:
fern docs md generate
Use fern docs md generate to generate MDX documentation pages from your library source code. The command reads libraries entries in docs.yml and produces pages for modules, classes, functions, and types.
For git inputs, the command sends the repository URL to Fern’s servers for parsing. For path inputs, pass --local to parse the source on your machine instead.
local
Use --local to parse library source locally rather than on Fern’s servers. Required when the library uses a path input. Local generation does not require authentication.
library
Use --library to generate docs for a single library when multiple libraries are configured.
When --library is omitted, all configured libraries are processed in parallel.
fern docs theme export
Use fern docs theme export to extract the theme-eligible fields from your docs.yml into a standalone directory. The exported theme.yml and its assets can then be uploaded with fern docs theme upload.
By default, files are written to ./fern/theme/.
output
Use --output to specify a custom directory for the exported theme.
fern docs theme upload
Use fern docs theme upload to upload a theme to Fern’s registry. The command reads theme.yml from ./fern/theme/ and uploads it along with any referenced file assets.
name
Use --name to set the theme name. Defaults to default.
org
Use --org to override the organization ID from fern.config.json.
fern docs link check
Use fern docs link check to scan a live documentation site for broken links. The command crawls the published site, checks every link, and reports broken (404) and blocked (403) URLs along with their source pages.
Unlike the broken-links rule in fern check, which validates only internal links in your local YAML navigation tree, fern docs link check checks all links — internal and external — on your live deployed site.
By default, the command auto-detects your docs URL from the instances in docs.yml. When all links are valid, the command exits with a success message.
The command first scrapes every page on the site, then checks each link it finds. When broken links are found, the output includes a summary and a grouped list of broken URLs with status codes and source file paths.
url
Use --url to specify which docs site to check. This is useful when you have multiple instances or want to check a preview deployment.
output
Use --output to control the output format. Supported values are text (default), json, and csv.
fern docs theme list
Use fern docs theme list to list all themes uploaded for your organization.
By default, outputs one theme name per line.
json
Use --json to output the full list as a JSON array, including updatedAt timestamps.
org
Use --org to override the organization ID from fern.config.json.