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 authentication
Option 1: Configure authentication via GitHub Actions
Use GitHub Actions to automatically publish new SDK versions to npm when you push code changes.
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.

Allow GitHub to run workflows
Change your workflow permissions to allow GitHub to run workflows:
- Click on the Settings tab in your repository.
- Under the Code and automation section, navigate to Actions > General.
- Under Actions permissions, select Allow all actions and reusable workflows.
- Save your settings. Now GitHub can run the actions you configure.
Add token to generators.yml
Add token: ${NPM_TOKEN}
to generators.yml
to tell Fern to use the NPM_TOKEN
environment variable (which you just configured in your GitHub repo) 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
Option 2: Configure via environment variables
Release your SDK to npm
Regenerate your SDK and publish it on 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.