# npm publish with a token? Move to trusted publishing before January

> npm trusted publishing uses short-lived OIDC credentials instead of stored tokens.

Source: https://fullbytedeveloper.com/blog/npm-trusted-publishing-migration
Keyword: NPMPUB
Published here: 2026-11-10

npm trusted publishing replaces stored tokens with short-lived, workflow-specific OIDC credentials. Tokens that bypass 2FA will lose direct publish access around January 2027 [1]. The two migration paths are trusted publishing (OIDC) and staged publishing (human approval).

## Configure trusted publishing on npm

1. Go to your package on npmjs.com.
2. Under Settings, find Trusted publishers.
3. Add a GitHub Actions workflow: specify the repository, workflow file, and optionally an environment.

The npm registry now accepts publishes from that workflow using OIDC.

## Update your workflow

Set `id-token: write` to let the workflow request an OIDC token. The npm CLI exchanges that token for a short-lived registry credential [3]:

```yaml
name: Publish
on:
  release:
    types: [published]
permissions:
  contents: read
  id-token: write
jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '22'
          registry-url: 'https://registry.npmjs.org'
      - run: npm ci
      - run: npm publish
```

You do not need `--provenance`. Publishing through trusted publishing from GitHub Actions generates provenance automatically [1] [2].

## Verify it works

Check the package page on npmjs.com. Packages published via trusted publishing show provenance information linking to the source repository and build.

## Restrict token access

After trusted publishing works, restrict traditional token access in the package settings. This reduces risk from leaked or stolen tokens [1].

Provenance proves which repository and workflow built the package. It does not prove the code is safe; it proves where it came from [2].

Send this to the friend who still publishes npm packages with a stored token.

## Sources

1. [npm docs: trusted publishing for npm packages](https://docs.npmjs.com/trusted-publishers/)
2. [npm docs: generating provenance statements](https://docs.npmjs.com/generating-provenance-statements/)
3. [GitHub changelog: npm trusted publishing with OIDC is generally available](https://github.blog/changelog/2025-07-31-npm-trusted-publishing-with-oidc-is-generally-available/)
