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. See Set up thefern
folder. - A GitHub repository for your TypeScript SDK. See Project structure.
- A TypeScript generator group in
generators.yml
. See TypeScript Quickstart.
Configure generators.yml
generators.yml
should live in your source repository (or on your local machine), not the repository that contains your TypeScript SDK code.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.
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 source 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.
Set up a new workflow
Set up a CI workflow that you can manually trigger from the GitHub UI. In your repository, navigate to Actions. Select New workflow, then Set up workflow yourself. Add a workflow that’s similar to this:
You can alternatively configure your workflow to execute on: [push]
. See Vapi’s npm publishing GitHub Action for an example.
Run your workflow
Navigate to the Actions tab, select the workflow you just created, specify a version number, and click Run workflow.
This regenerates your SDK, tags the new release with the version number you specified, and initiates a Fern-generated publishing workflow in your TypeScript SDK repository that publishes your release to npm.

Once your workflow completes, log back into npm and navigate to Packages to see your new release.
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.
Regenerate your SDK
Regenerating your SDK tags the new release with the version number you specified and initiates a Fern-generated publishing workflow in your TypeScript SDK repository that publishes your release to npm.
Local machine output will verify that the release is pushed to your repository and tagged with the version you specified. Log back into npm and navigate to Packages to see your new release.