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.13.0
221stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
90/100Excellent
Development Activity96
Maintenance100
Community84
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
80/100Excellent
Architecture85
Code Quality90
Innovation65
Learning Curve80

@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 8 apps in this directory

Rust
53%
Other

Cap

Team Chat · Video Conferencing

21,859

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
Rust53%
TypeScript43%
Updated yesterday
TypeScript
84%
Apache 2.0

Continue

Developer Tools · AI Development · AI Code Assistants

35,808

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

View details
81
Repo Health
88
Technical
62
Dependency
Built with
TypeScript84%
Updated yesterday
TypeScript
45%
Other

Convex Backend

Developer Tools · Databases

12,494

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
TypeScript45%
Rust43%
Updated 2 days ago
Go
75%
MIT

Digger

Devops · Automation · Developer Tools

5,040

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

View details
68
Repo Health
73
Technical
67
Dependency
Built with
Go75%
TypeScript15%
Updated 3 weeks ago
TypeScript
99%
Apache 2.0

Mastra Code

AI Code Assistants

27,743

"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
88
Repo Health
73
Technical
65
Dependency
Built with
TypeScript99%
Updated today
TypeScript
41%
MIT

MentraOS

Developer Tools · AI Development

2,336

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
TypeScript41%
Java24%
Kotlin10%
Updated yesterday
TypeScript
97%
Other

nango

Developer Tools · Automation · Authentication

11,746

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

View details
93
Repo Health
85
Technical
68
Dependency
Built with
TypeScript97%
Updated 3 days ago
Go
55%
AGPL 3.0

Unkey

Developer Tools

5,432

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
Go55%
TypeScript43%
Updated yesterday

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

Search