Publishing to npm
Publish your public-facing Fern TypeScript SDK to the npm registry. After following the steps on this page, you’ll have a versioned package published on npm.

This page assumes that you have:
- An initialized
fern
folder on your local machine. See Set up thefern
folder. - A GitHub repository for your TypeScript SDK. See Set up your GitHub structure.
- A TypeScript generator group in
generators.yml
. See TypeScript Quickstart.
Configure generators.yml
Configure output
location
In the group
for your TypeScript SDK, change the output location in from local-file-system
(the default) to npm
to indicate that Fern should publish your package directly to the npm registry:
Add a unique package name
Your package name must be unique in the npm repository, otherwise publishing your SDK to npm will fail. Update your package name if you haven’t done so already:
Generate an npm token
Generate Token
Click on Generate New Token, then choose the appropriate token type.
Option 1: Classic Token
- Select Classic Token
- Name your token and select Automation as the token type.
- Click Generate Token.

Option 2: Granular Access Token
- Select Granular Access Token.
- Name your token.
- Set an expiration.
- Configure your token’s access to packages and scopes.
- Configure your token’s access to organizations. In order to fill this out, you must have at least one organization already configured in npm. See Creating an organization for more information.
- Optionally fill out additional permissions according to your organization’s requirements.
- Click Generate Token.

Configure npm publication
Choose how you want to authenticate and publish your SDK to npm. You can use GitHub workflows for automated releases or publish directly via the CLI.
Release via a GitHub workflow (recommended)
Set up a release workflow via GitHub Actions so you can trigger new SDK releases directly from your repository.
Set up authentication
Open your Fern repository in GitHub. Click on the Settings tab in your repository. Then, under the Security section, open Secrets and variables > Actions.

You can also use the url https://github.com/<your-repo>/settings/secrets/actions
.
Add secret for your npm Token
- Select New repository secret.
- Name your secret
NPM_TOKEN
. - Add the corresponding token you generated above.
- Click Add secret.

Add secret for your Fern Token
- Select New repository secret.
- Name your secret
FERN_TOKEN
. - Add your Fern token. If you don’t already have one, generate one by running
fern-token
. By default, thefern_token
is generated for the organization listed infern.config.json
. - Click Add secret.

Release via CLI and environment variables
Configure npm authentication token
Add token: ${NPM_TOKEN}
to generators.yml
to tell Fern to use the NPM_TOKEN
environment variable for authentication when publishing to the npm registry.
When you regenerate your release, Fern will automatically create a workflow in your repository called .github/workflows/ci.yml
that will automatically publish your release to npm. For an example, see Vapi’s npm publishing GitHub Action