Skip to main content
We welcome contributions to the WorkOS Node SDK! This guide will help you get started.

Getting Started

Prerequisites

Before contributing, ensure you have:
  • Node.js 20.15.0 or higher
  • npm 10 or higher
  • Git
  • A GitHub account

Repository Setup

1

Fork the Repository

Fork the workos-node repository to your GitHub account.
2

Clone Your Fork

git clone https://github.com/YOUR_USERNAME/workos-node.git
cd workos-node
3

Install Dependencies

npm install
4

Create a Branch

git checkout -b feature/your-feature-name

Development Workflow

Project Structure

workos-node/
├── src/               # TypeScript source code
│   ├── workos.ts      # Main WorkOS class
│   ├── user-management/
│   ├── sso/
│   ├── directory-sync/
│   └── ...
├── lib/               # Compiled output (generated)
├── package.json       # Package configuration
├── tsconfig.json      # TypeScript configuration
└── tsdown.config.ts   # Build configuration

Available Scripts

# Development
npm run build          # Build the project
npm run build:watch    # Build in watch mode
npm run typecheck      # Check TypeScript types

# Testing
npm test               # Run tests
npm run test:watch     # Run tests in watch mode

# Code Quality
npm run lint           # Lint code
npm run format         # Format code with Prettier
npm run prettier       # Check formatting

# Runtime Checks
npm run check:runtimes # Test across Node.js, Deno, Bun, Cloudflare Workers
npm run check:types    # Validate type definitions

Making Changes

1

Write Your Code

Make your changes in the src/ directory. The SDK is written in TypeScript with strict type checking enabled.
2

Add Tests

Write tests for your changes in .spec.ts files alongside your code.
// Example: src/user-management/user-management.spec.ts
describe('UserManagement', () => {
  it('should get a user', async () => {
    // Test implementation
  });
});
3

Run Type Checking

npm run typecheck
4

Run Tests

npm test
5

Lint and Format

npm run lint
npm run format

Code Guidelines

TypeScript Style

The SDK uses strict TypeScript configuration:
// ✅ Good: Explicit types
interface CreateUserOptions {
  email: string;
  firstName?: string;
  lastName?: string;
}

async function createUser(options: CreateUserOptions): Promise<User> {
  // Implementation
}

// ❌ Bad: Implicit any types
async function createUser(options) {
  // Implementation
}

Code Formatting

We use Prettier for code formatting. Run npm run format before committing.

Naming Conventions

  • Files: Use kebab-case (user-management.ts, get-user-options.interface.ts)
  • Classes: Use PascalCase (WorkOS, UserManagement)
  • Interfaces: Use PascalCase (User, CreateUserOptions)
  • Functions: Use camelCase (getUser, listOrganizations)
  • Constants: Use UPPER_SNAKE_CASE (DEFAULT_HOSTNAME, HEADER_AUTHORIZATION)

File Organization

Each module should have:
module-name/
├── module-name.ts              # Main implementation
├── module-name.spec.ts         # Tests
├── interfaces/                  # TypeScript interfaces
│   ├── index.ts
│   ├── entity.interface.ts
│   └── options.interface.ts
└── serializers/                 # Data transformation
    ├── index.ts
    └── entity.serializer.ts

Testing

Writing Tests

Tests use Jest and follow the Arrange-Act-Assert pattern:
import { WorkOS } from '../workos';
import fetchMock from 'jest-fetch-mock';

describe('UserManagement', () => {
  beforeEach(() => fetchMock.resetMocks());
  
  describe('getUser', () => {
    it('should return a user', async () => {
      // Arrange
      const workos = new WorkOS('sk_test_123');
      fetchMock.mockResponseOnce(JSON.stringify({
        id: 'user_123',
        email: '[email protected]',
        // ...
      }));
      
      // Act
      const user = await workos.userManagement.getUser({ 
        userId: 'user_123' 
      });
      
      // Assert
      expect(user.id).toBe('user_123');
      expect(user.email).toBe('[email protected]');
    });
  });
});

Test Coverage

Aim for high test coverage:
  • Unit tests for all public methods
  • Integration tests for critical workflows
  • Edge case and error handling tests

Running Tests

# Run all tests
npm test

# Run specific test file
npm test user-management.spec.ts

# Run in watch mode
npm run test:watch

# Run with coverage
npm test -- --coverage

Pull Request Process

Before Submitting

  • Code follows the project’s style guidelines
  • All tests pass (npm test)
  • Type checking passes (npm run typecheck)
  • Code is formatted (npm run format)
  • New features include tests
  • Breaking changes are documented
  • Commit messages are clear and descriptive

Submitting a Pull Request

1

Push Your Branch

git push origin feature/your-feature-name
2

Open a Pull Request

Go to the workos-node repository and click “New Pull Request”.
3

Fill Out the Template

Provide a clear description of your changes:
  • What does this PR do?
  • Why is this change needed?
  • Are there any breaking changes?
  • How was it tested?
4

Wait for Review

A maintainer will review your PR and may request changes. Address any feedback and push updates to your branch.

PR Title Format

Use conventional commit format:
type(scope): description

Examples:
feat(user-management): add PKCE authentication support
fix(sso): correct authorization URL parameter handling
docs(readme): update installation instructions
test(directory-sync): add tests for custom attributes
Types:
  • feat: New feature
  • fix: Bug fix
  • docs: Documentation changes
  • test: Test additions or changes
  • refactor: Code refactoring
  • chore: Build process or tooling changes

Reporting Issues

Bug Reports

When reporting bugs, include:
  • SDK version
  • Node.js version
  • Operating system
  • Minimal code example to reproduce
  • Expected vs actual behavior
  • Error messages or stack traces

Feature Requests

For feature requests, describe:
  • The problem you’re trying to solve
  • Your proposed solution
  • Alternative solutions you’ve considered
  • Any additional context

Documentation

If your changes affect the public API:
  • Update JSDoc comments in the code
  • Update README.md if needed
  • Consider if documentation site updates are needed
/**
 * Get a user by ID.
 *
 * @param options - Options for getting a user
 * @param options.userId - The ID of the user to get
 * @returns The user object
 * @throws {NotFoundException} If the user is not found
 *
 * @example
 * ```typescript
 * const user = await workos.userManagement.getUser({ 
 *   userId: 'user_123' 
 * });
 * ```
 */
async getUser(options: GetUserOptions): Promise<User> {
  // Implementation
}

Release Process

Maintainers handle releases using semantic versioning:
  • Patch (X.Y.Z): Bug fixes, no breaking changes
  • Minor (X.Y.0): New features, backwards compatible
  • Major (X.0.0): Breaking changes
Releases are automated via release-please.

Code of Conduct

By contributing, you agree to:
  • Be respectful and inclusive
  • Provide constructive feedback
  • Focus on what is best for the community
  • Show empathy towards others

Getting Help

Need help with your contribution?

Recognition

All contributors are recognized in:
  • The project’s CHANGELOG.md
  • GitHub’s contributors page
  • Release notes
Thank you for contributing to WorkOS!

Additional Resources

GitHub Repository

View source code and open issues

API Reference

Official WorkOS API documentation

WorkOS Dashboard

Manage your WorkOS account

Community

Join the WorkOS community

Build docs developers (and LLMs) love