Authentication Guide

Install Three Blocks in 60 Seconds

You purchased a license—now let's get your packages installing locally and deploying seamlessly to Vercel, GitHub Actions, and beyond.

License Required

Get started with Three Blocks by subscribing to access private packages.

Install locally

Set up Three Blocks packages on your development machine

Deploy to Vercel

Configure environment variables for production builds

Troubleshoot issues

Fix common 401 errors and authentication problems

Choose Your Setup Method

Two ways to authenticate with Three Blocks packages. We recommend the automatic method for production and CI/CD workflows.

Recommended

Automatic (Preinstall Hook)

Authentication runs automatically before every install. Perfect for teams and deployments.

Benefits:

  • Works seamlessly in CI/CD (Vercel, GitHub Actions, etc.)
  • Tokens auto-refresh, never expires
  • Team members don't need manual setup
  • Set and forget
Setup Automatic Method →

Manual (CLI)

Run a CLI command once to authenticate. Best for local development and quick testing.

Benefits:

  • Simpler concept, explicit control
  • No package.json changes needed
  • Good for learning how it works

Limitations:

  • Tokens expire after 12 hours
  • Requires manual re-authentication
  • Not ideal for CI/CD without extra setup
Setup Manual Method →
Recommended

Method 1: Automatic Authentication

Set up once, works everywhere. This method uses a preinstall hook to authenticate automatically before every package install.

1

Configure Registry

Create a .npmrc file in your project root. The registry URL depends on your plan.

Indie Plan .npmrc
@three-blocks:registry=https://three-blocks-196905988268.d.codeartifact.ap-northeast-1.amazonaws.com/npm/core/
Pro / Company Plan .npmrc
@three-blocks:registry=https://three-blocks-196905988268.d.codeartifact.ap-northeast-1.amazonaws.com/npm/pro/

Safe to commit - This file contains no secrets. Commit it to git.

2

Add Preinstall Hook

Add this to your package.json. It runs the authentication CLI automatically before every install.

package.json
{
  "scripts": {
    "preinstall": "npx -y three-blocks-login@latest"
  }
}

💡 Package manager alternatives:

pnpm: "preinstall": "pnpm dlx three-blocks-login@latest"

yarn: "preinstall": "npx -y three-blocks-login@latest"

bun: "preinstall": "bunx three-blocks-login@latest"

3

Set License Key

Set your license key as an environment variable. Your key starts with tb_ and can be found in your account dashboard.

For local development, create a .env.local file:

.env.local
THREE_BLOCKS_SECRET_KEY=tb_your-license-key-here

Or export in your terminal session:

terminal
export THREE_BLOCKS_SECRET_KEY="tb_your-license-key-here"

⚠️ Never commit secrets - Add .env.local to your .gitignore.

4

Install Packages

Now just install packages normally. The preinstall hook handles authentication automatically.

terminal
pnpm install @three-blocks/core

🎉

That's it! You're all set.

The preinstall hook will run before every install, keeping your authentication fresh.

Manual

Method 2: Manual CLI Authentication

Run the authentication CLI when you need it. The CLI will prompt for your license key interactively.

1

Run Authentication CLI

Run the CLI and it will prompt you for your license key interactively. It then configures your .npmrc automatically.

terminal
pnpm dlx three-blocks-login

💡 The CLI will ask for your license key if THREE_BLOCKS_SECRET_KEY is not set. It then writes both the registry URL and auth token to your .npmrc.

Optional: Set license key as environment variable

If you prefer to skip the interactive prompt, export your key first:

terminal
export THREE_BLOCKS_SECRET_KEY="tb_your-license-key-here"
pnpm dlx three-blocks-login
2

Install Packages

Now you can install Three Blocks packages normally.

terminal
pnpm install @three-blocks/core

Done!

You're authenticated and ready to install packages.

Remember: Tokens Expire

Auth tokens expire after 12 hours. When you see authentication errors, just run pnpm dlx three-blocks-login again.

This is why we recommend the automatic method for production—it refreshes tokens automatically.

How It Works

Three Blocks packages are hosted on AWS CodeArtifact, a private npm registry. When you install packages, npm/pnpm needs to authenticate with this registry.

The Authentication Flow

  1. 1 You run pnpm install
  2. 2 The preinstall script runs three-blocks-login
  3. 3 three-blocks-login sends your license key to our broker service
  4. 4 The broker validates your license and returns a short-lived npm token (valid for 12 hours)
  5. 5 The token is written to your .npmrc file
  6. 6 npm/pnpm uses this token to download packages from CodeArtifact

💡 Why the preinstall script? Tokens expire after 12 hours for security. The preinstall script ensures you always have a fresh token before installing packages, so you never hit authentication errors.

Platform Setup Guides

Choose your deployment platform for detailed setup instructions:

Deploy to Vercel

This is where most users deploy. We know auth setup can be frustrating, so we've broken it down step-by-step.

Before You Start

You've completed the Quick Start and packages install locally
Your .npmrc file is committed to git
Your repository is connected to Vercel
1

Add Environment Variable

Go to your project settings in Vercel and add the THREE_BLOCKS_SECRET_KEY environment variable.

1. Open your project in Vercel

2. Go to SettingsEnvironment Variables

3. Add a new variable:

Key:

THREE_BLOCKS_SECRET_KEY

Value:

tb_your-license-key

⚠️ Important: Enable this variable for all environments (Production, Preview, Development)

2

Verify .npmrc is Committed

Vercel needs the .npmrc file to know where to find Three Blocks packages. Make sure it's in your git repository.

terminal
git status
# .npmrc should NOT appear in untracked files

git add .npmrc
git commit -m "Add npmrc for Three Blocks registry"
git push
3

Trigger a New Deployment

Push a new commit or trigger a redeploy from the Vercel dashboard. Your build should now succeed!

You should see: Installing dependencies... followed by successful installation of @three-blocks/core

😱 Getting 401 Unauthorized Errors?

If your Vercel build fails with authentication errors, check:

  • Is THREE_BLOCKS_SECRET_KEY set in Vercel environment variables?
  • Is the environment variable enabled for the correct environment (Production/Preview)?
  • Is your .npmrc file committed to your repository?
  • Is your license key valid? Check your account dashboard
View detailed troubleshooting guide →
⚙️

GitHub Actions Setup

Configure CI/CD pipelines to build and test with Three Blocks packages.

Step 1: Add Repository Secret

Go to your GitHub repository settings and add your license key as a secret:

  1. 1. Go to SettingsSecrets and variablesActions
  2. 2. Click New repository secret
  3. 3. Name: THREE_BLOCKS_SECRET_KEY
  4. 4. Value: Your license key (starts with tb_)

Step 2: Update Workflow File

Add the environment variable to your workflow file:

.github/workflows/ci.yml
name: CI

on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20'

      - name: Install pnpm
        uses: pnpm/action-setup@v2
        with:
          version: 8

      - name: Install dependencies
        env:
          THREE_BLOCKS_SECRET_KEY: ${{ secrets.THREE_BLOCKS_SECRET_KEY }}
        run: pnpm install

      - name: Build
        run: pnpm build

      - name: Test
        run: pnpm test

💡 Key point: The env section passes the secret to the install step where the preinstall script can access it.

Netlify Setup

Deploy with Netlify's edge network and CDN.

Netlify setup is similar to Vercel. The key is adding your license key as an environment variable.

Add Environment Variable

  1. 1. Open your site in Netlify
  2. 2. Go to Site settingsEnvironment variables
  3. 3. Click Add a variable
  4. 4. Key: THREE_BLOCKS_SECRET_KEY
  5. 5. Value: Your license key
  6. 6. Click Create variable
  7. 7. Trigger a new deploy

✅ That's it! Your builds should now have access to Three Blocks packages.

Other Platforms

Railway, Render, or any platform with environment variables support.

Generic Setup Steps

For any CI/CD or deployment platform, follow these universal steps:

  1. 1
    Commit .npmrc

    Make sure your .npmrc file with the registry URL is committed to git

  2. 2
    Set Environment Variable

    Add THREE_BLOCKS_SECRET_KEY=tb_your-key to your platform's environment variables

  3. 3
    Verify preinstall Script

    Ensure your package.json has the preinstall script

  4. 4
    Deploy

    Trigger a build—the preinstall script will authenticate before installing packages

Troubleshooting

401 Unauthorized Error

npm/pnpm says "Unable to authenticate" when installing packages

Problem: License key not set

The THREE_BLOCKS_SECRET_KEY environment variable is missing or empty.

Solution: Set the environment variable in your terminal or .env.local file

Problem: Invalid license key

Your license key is incorrect, expired, or your subscription is inactive.

Solution: Verify your license key in your account dashboard and check your subscription status

Problem: Token expired

npm tokens expire after 12 hours. Your cached token may be stale.

Solution: Run pnpm dlx three-blocks-login@latest manually to refresh the token

Problem: .npmrc missing registry URL

Your .npmrc doesn't have the Three Blocks registry configuration.

Solution: Add the registry URL to your .npmrc:

@three-blocks:registry=https://three-blocks-196905988268.d.codeartifact.ap-northeast-1.amazonaws.com/npm/core/
📦

Package Not Found

npm/pnpm says @three-blocks/core doesn't exist

Cause

npm/pnpm is looking for the package on the public npm registry instead of the Three Blocks private registry.

Solution

Make sure your .npmrc has the correct registry configuration for your plan:

Indie Plan:

@three-blocks:registry=https://three-blocks-196905988268.d.codeartifact.ap-northeast-1.amazonaws.com/npm/core/

Pro / Company Plan:

@three-blocks:registry=https://three-blocks-196905988268.d.codeartifact.ap-northeast-1.amazonaws.com/npm/pro/

Vercel Build Fails

Works locally but fails on Vercel

Check these items in order:

1. Environment variable set?

Go to Vercel project settings → Environment Variables → Verify THREE_BLOCKS_SECRET_KEY exists and is enabled for your environment

2. .npmrc committed?

Run git ls-files .npmrc - if it returns nothing, your .npmrc is not committed

3. Preinstall script present?

Check package.json has the preinstall script

4. Check build logs

Look for "preinstall" in the logs - you should see three-blocks-login running and outputting "✓ Authentication successful"

Security Best Practices

Safe to Commit

  • .npmrc with registry URL only (no tokens)
  • package.json with preinstall script
  • Build configuration files

Never Commit

  • .npmrc with auth tokens
  • .env.local with license keys
  • Any file containing your tb_ license key

🔒 Token Security

  • Tokens expire after 12 hours - This is intentional for security. The preinstall script automatically refreshes them.
  • License keys don't expire - As long as your subscription is active, your license key remains valid.
  • One key per subscription - Your license key works for all your projects and environments.

Still Having Issues?

We're here to help! Reach out through any of these channels: