Node logo

Integrate WorkOS using the Node SDK

Easily add enterprise features like Single Sign-On (SSO/SAML), Directory Sync (SCIM), Audit Trail (SIEM), and Access Control (IAM) to your Node app.

Installation

We publish our Node SDK on npm. You can install the SDK using npm with the following command:

Terminal

file_copy
npm install @workos-inc/node

Or, with yarn:

Terminal

file_copy
yarn add @workos-inc/node

Usage

Below is an example integration that adds SSO using the Node SDK. You can find other examples and more information in our Node SDK Docs.

Node

file_copy
import WorkOS from '@workos-inc/node';

const client = new WorkOS('WORKOS_API_SECRET_KEY');
const projectID = 'PROJECT_ID';
const redirectURI = 'REDIRECT_URI';
const domain = 'example.com'; // Hardcode this for now; you'll need to get this from a user

app.get('/login', (_req, res) => {
  const url = client.sso.getAuthorizationURL({
    domain,
    redirectURI,
    projectID,
  });

  res.redirect(url);
});

app.get('/callback', async (req, res) => {
  const { code } = req.query;
  const profile = await client.sso.getProfile({
    code,
    projectID,
  });

  res.json(profile).send();
});

Start Integrating Today

Create an account to begin adding enterprise-ready features to your application today.