WorkOS AuthKit

Sync WorkOS AuthKit authentication events and user data directly into your Convex database with pre-built webhooks and queries.

Installation

npm install @convex-dev/workos-authkit

About WorkOS AuthKit

This component is the official way to integrate WorkOS AuthKit authentication with your Convex project.

Features:

Sync user data from WorkOS to your Convex database reliably and durably.
Respond to events with Convex functions.
See example for a demo of how to incorporate this component into your application.

Open a GitHub issue with any feedback or bugs you find.

Prerequisites#
Follow the Convex WorkOS AuthKit guide to set up a working project with WorkOS AuthKit.

Then follow the steps below to set up user data syncing and event handling.

Benefits

Use cases

how to sync WorkOS users to Convex database

The @convex-dev/workos-authkit component automatically syncs user data from WorkOS AuthKit to your Convex database through webhook handlers. It creates and updates user records when authentication events occur, keeping your local user data in sync without manual API calls.

WorkOS webhook integration with Convex

This component provides pre-built webhook endpoints that handle WorkOS AuthKit events like user creation, updates, and deletions. The webhooks automatically trigger Convex actions to update your database, eliminating the need to write custom webhook parsing logic.

access WorkOS user data in Convex queries

After syncing with @convex-dev/workos-authkit, you can query WorkOS user profiles and organization data directly from Convex without external API calls. The component stores user attributes, roles, and organization memberships in your Convex database for fast local access.

Frequently asked questions

How does WorkOS AuthKit component handle user data synchronization?

The @convex-dev/workos-authkit component uses WorkOS webhooks to automatically sync user data to your Convex database. When users sign up, update profiles, or change organizations in WorkOS, the component receives webhook events and updates the corresponding records in Convex through built-in actions.

What WorkOS AuthKit events are supported by this component?

The component handles standard WorkOS AuthKit events including user creation, profile updates, organization membership changes, and user deletions. Each event type triggers corresponding Convex actions that maintain data consistency between WorkOS and your Convex database.

Can I customize how WorkOS user data is stored in Convex?

Yes, the @convex-dev/workos-authkit component allows you to customize the database schema and data transformation logic. You can modify which user attributes are stored, add custom fields, and define how organization data maps to your Convex tables while maintaining the automatic synchronization.

Does this component require specific Convex schema setup?

The @convex-dev/workos-authkit component includes recommended schema definitions for storing WorkOS user and organization data in Convex. You can use the provided schemas or adapt them to fit your existing database structure while ensuring compatibility with the synchronization actions.

Links