workos-node

Official Node.js SDK for the WorkOS API, wrapping SSO, SCIM directory sync, and enterprise user management in a typed client.

SDK
npm
v10.14.0
221 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
90 /100 Excellent
Development Activity 96
Maintenance 100
Community 84
Maturity 60
Momentum 20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
80 /100 Excellent
Architecture 85
Code Quality 90
Innovation 65
Learning Curve 80

@workos-inc/node is the official server-side client for the WorkOS API, giving Node and TypeScript applications a single typed entry point into WorkOS’s enterprise-readiness building blocks: SSO, Directory Sync (SCIM), User Management/AuthKit, Multi-Factor Auth, Audit Logs, Admin Portal, Feature Flags, and more. Rather than hand-rolling OAuth/SAML flows and SCIM parsing per customer, teams instantiate a single WorkOS client and call domain-scoped modules (workos.sso, workos.directorySync, workos.userManagement, …) that each map to a documented WorkOS API resource.

The SDK builds on the fetch API so it runs unmodified across Node, edge runtimes (Cloudflare Workers/workerd, Vercel Edge, Convex), and browser/mobile clients in a credential-less PKCE mode. It automatically retries transient failures (network errors, 408/429/5xx) with exponential backoff and jitter, honors Retry-After headers, and assigns idempotency keys to retried writes so a retried POST is never double-applied.

What You Get

  • A single WorkOS client exposing typed sub-clients for every API domain: sso, directorySync, userManagement, organizations, auditLogs, multiFactorAuth, adminPortal, webhooks, featureFlags, vault, widgets, and more
  • Built-in PKCE support for public clients (browser/mobile/CLI apps that can’t hold a secret), including getAuthorizationUrlWithPKCE and code-verifier exchange helpers
  • Automatic transient-failure retries with exponential backoff, jitter, Retry-After support, and idempotency-key assignment on retried writes
  • Multi-runtime builds (index.mjs/index.cjs for Node, index.worker.mjs/index.worker.cjs for Cloudflare Workers, edge-light, and Convex) selected automatically via package.json exports conditions
  • Typed request/response interfaces and a structured exception hierarchy (UnauthorizedException, RateLimitExceededException, UnprocessableEntityException, OauthException, etc.) mapped from WorkOS HTTP status codes

Common Use Cases

  • Adding enterprise SSO (SAML/OIDC) login to a B2B SaaS product without implementing each customer’s identity provider handshake directly
  • Syncing customer HR/directory groups and users into your app via SCIM, keeping org membership in sync automatically
  • Building a full AuthKit-based user management flow (sign-up, sign-in, MFA, session refresh) for a Node or edge-deployed app
  • Verifying and consuming WorkOS webhooks for org/directory/user lifecycle events inside an existing Node backend
  • Rendering a self-serve Admin Portal so enterprise customers can configure their own SSO/directory connections without support tickets

Under The Hood

Architecture The WorkOS class in src/workos.ts is the sole composition root: its constructor resolves an API key or client ID (from arguments or WORKOS_API_KEY/WORKOS_CLIENT_ID env vars), builds a FetchHttpClient bound to api.workos.com, and eagerly instantiates one client instance per domain (Agents, ApiKeys, Connect, DirectorySync, Organizations, SSO, Webhooks, UserManagement, Vault, Widgets, and roughly fifteen more) as readonly properties, each taking the parent WorkOS instance and delegating HTTP calls back through its shared get/post/put/patch/delete methods. A centralized handleHttpError translates HTTP status codes (401, 404, 409, 422, 429, plus OAuth/authentication-shaped error bodies) into a typed exception hierarchy under common/exceptions, so every domain module raises consistent, typed errors from one place rather than each reimplementing status-code branching. Domain modules are organized as sibling directories (sso/, directory-sync/, user-management/, audit-logs/, …) each with its own interfaces, serializers, and fixtures, giving a modular one-class-per-API-resource structure with no cross-module coupling beyond the shared client.

Tech Stack Written in TypeScript, built with tsdown into dual ESM/CJS bundles plus separate Cloudflare Workers/edge-light/Convex builds selected via package.json exports conditions, targeting Node >=22.11. The HTTP layer is a thin FetchHttpClient wrapper around the global fetch API (no axios/node-fetch dependency), with iron-webcrypto, jose, and uint8array-extras inlined directly into the bundle as pinned dependencies rather than left as external npm deps, avoiding version-skew issues for consumers. PKCE/session cryptography goes through a SubtleCryptoProvider built on the standard Web Crypto API, which is what makes the same code path work identically in Node, Workers, and edge runtimes.

Code Quality Extensive test coverage: fifty-plus *.spec.ts files sit alongside their implementation files (one per domain module, plus dedicated specs for the HTTP client, PKCE, and the package’s public barrel export), run with Jest against jest-fetch-mock-mocked responses. CI (GitHub Actions, matrixed across Node 22 and 24) runs Prettier, ESLint (via typescript-eslint), tsc --noEmit typechecking, a full build, and the test suite on every push and PR — a comprehensive, enforced quality gate rather than tests-only. Error handling is explicit and typed throughout (a dedicated exception class per HTTP-error shape) rather than swallowed or stringly-typed.

What Makes It Unique Rather than being a generic HTTP wrapper, the SDK’s value is in encoding WorkOS’s specific enterprise-identity domain model (SSO connections, directory groups/users, organization domains, admin portal sessions) as first-class typed objects, plus dual-mode operation: a secret-holding server client and a secret-less PKCE public client from the same package, letting one library cover both a Node backend and a browser/mobile/CLI frontend flow for the same WorkOS integration.

Used by 9 apps in this directory

Go
59%
Apache 2.0

agent-orchestrator

AI Agents · AI Code Assistants · Developer Tools

12,440

A local desktop workspace that gives every coding task its own agent, Git branch, and worktree, then tracks tasks, pull requests, CI, and reviews for 27 coding agents on one live Kanban board.

View details
86
Repo Health
83
Technical
68
Dependency
Built with
Go 59%
TypeScript 38%
Updated 4 days ago
Rust
54%
Other

Cap

Team Chat · Video Conferencing

22,884

Open source Loom alternative with GPU-accelerated recording, instant share links, AI summaries, and full self-hosting via Docker Compose.

View details
89
Repo Health
81
Technical
64
Dependency
Built with
Rust 54%
TypeScript 42%
Updated 4 days ago
TypeScript
84%
Apache 2.0

Continue

AI Code Assistants · AI Development · Automation

36,049

Open-source coding agent for VS Code, JetBrains, and CLI with support for 30+ LLM providers.

View details
73
Repo Health
88
Technical
62
Dependency
Built with
TypeScript 84%
Updated 5 days ago
TypeScript
45%
Other

Convex Backend

Databases · Developer Tools

12,617

Open-source reactive database that lets developers build live-updating apps with pure TypeScript, strong consistency, and real-time subscriptions—no separate API layer required.

View details
87
Repo Health
82
Technical
68
Dependency
Built with
TypeScript 45%
Rust 43%
Updated 6 days ago
Go
75%
MIT

Digger

Automation · Developer Tools · Devops

5,044

Run Terraform and OpenTofu natively inside your existing CI pipeline — no separate runners, no third-party secrets, no extra compute costs.

View details
74
Repo Health
73
Technical
67
Dependency
Built with
Go 75%
TypeScript 15%
Updated 1 weeks ago
TypeScript
99%
Apache 2.0

Mastra Code

AI Code Assistants

28,378

"A coding agent that never compacts" — a terminal-based AI coding agent built on the Mastra framework, with Observational Memory instead of context compaction, multi-model support, and OAuth login for Claude Max or ChatGPT Plus.

View details
90
Repo Health
73
Technical
65
Dependency
Built with
TypeScript 99%
Updated 4 days ago
TypeScript
42%
MIT

MentraOS

AI Development · Developer Tools

2,370

The open source operating system and SDK that lets developers build one app and run it across smart glasses from Even Realities, Vuzix, Mentra Live, and more.

View details
92
Repo Health
77
Technical
66
Dependency
Built with
TypeScript 42%
Java 20%
Kotlin 13%
Updated 4 days ago
TypeScript
97%
Other

nango

Authentication · Automation · Developer Tools

12,376

Build product integrations with AI using 800+ APIs — auth, proxy, and TypeScript functions on production-grade infrastructure.

View details
93
Repo Health
85
Technical
67
Dependency
Built with
TypeScript 97%
Updated 1 weeks ago
Go
58%
AGPL 3.0

Unkey

Developer Tools

5,450

An open-source developer platform for API infrastructure — issue and verify API keys, enforce global rate limits, route traffic through a gateway, and get per-key analytics and audit logs.

View details
91
Repo Health
70
Technical
68
Dependency
Built with
Go 58%
TypeScript 41%
Updated 5 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers