Boundary
Guide

Usage

Learn how to initialize and use the Boundary SDK in your applications.

IMPORTANT

Boundary requires async initialization. Always use Boundary.create(). Never use new Boundary() - the constructor is private and will fail.

Basic Initialization

Initialize Boundary with your provider configuration for local development.

index.ts
import { Boundary } from "boundary-sdk";

// ✅ CORRECT: Async initialization
const boundary = await Boundary.create({
  github: {
    auth: {
      token: process.env.GITHUB_TOKEN
    },
  },
  localUnsafe: true, // Required for local development without StateStorage
});

const { data, meta } = await boundary.github.get("/users/octocat");
console.log(meta.rateLimit.remaining);

Production Deployment

For distributed deployments, you must provide a StateStorage implementation for shared state management.

production.ts
import { Boundary } from "boundary-sdk";
import { RedisStateStorage } from "./your-redis-storage.js";

const boundary = await Boundary.create({
  mode: "distributed",
  stateStorage: new RedisStateStorage(redisClient),
  github: {
    auth: { token: process.env.GITHUB_TOKEN },
  },
});