Overview

Manage and configure your Fern projects, all from the command line.
View as Markdown

Install Fern CLI

Run the following command to download and install Fern CLI from the npm registry.

$npm install -g fern-api # install Fern CLI
>fern -v # ensure Fern was successfully installed

If you’re experiencing network delays with the global installation, working in an environment with limited internet connectivity, or prefer to manage Fern as a project dependency, you can install the CLI locally:

1

Install as project dependency

Add fern-api to your project dependencies:

$npm install fern-api
2

Update configuration

In your fern.config.json, set the version to * to use your locally installed version:

fern.config.json
1{
2 "organization": "your-org",
3 "version": "*"
4}

See the fern.config.json reference for more details.

3

Run via package manager

Use your package manager to run Fern commands:

$npm fern check # Validate API definition
>npm fern --version # Check CLI version
>npm fern generate # Generate outputs

CLI quickstart

Get started with these commonly used commands:

Common Commands
$# Docs Development
>fern init --docs # Create a new documentation project
>fern docs dev # Preview docs locally at localhost:3000
>fern generate --docs --preview # Preview documentation changes
>fern generate --docs # Generate and publish documentation
>
># SDK Development
>fern init # Start new SDK project
>fern check # Validate API definition
>fern generate --preview # Preview SDKs in .preview/ folder
>fern generate # Generate default SDK group
>fern generate --group ts-sdk # Generate specific SDK group

The “default SDK group” refers to the group marked as default in your generators.yml. Learn more about default groups.

Common workflows

  1. Initialize a new docs project:
$fern init --docs
  1. Preview locally while making changes:
$fern docs dev
  1. When ready to preview or publish:
$fern generate --docs --preview # Generate a shareable preview link
>fern generate --docs # Publish to production
  1. Initialize a new SDK project:
$fern init
  1. Configure your generators in configuration options

  2. Generate SDKs:

$fern generate --preview # Preview changes locally
>fern generate --group python-sdk --preview # Preview specific SDK group
>fern generate # Publish to production

During development, use --preview to test your changes locally before publishing. The preview SDK will be generated into the .preview/ folder.