John
John11mo ago

WorkOS Authkit as Custom Auth Integration with Convex

Currently having some trouble figuring out how to use WorkOS Authkit as Custom Auth with Convex. - there doesn't seem to be an equivalent of an AuthProviderXReactProvider - not sure how to update the useAuthFromProviderX reference to use with ConvexProviderWithAuth so that ctx.auth.getUserIdentity() works correctly - not sure what to provide as the domain and applicationID in the auth.config.js file I've tried referencing this next-authkit-example, the convex clerk example, and the nextauth example by Web Dev Cody, but still not sure how to get it working with convex. The WorkOS docs mention that:
In order to persist the authenticated state of the user in the application, we need to store and access a session. WorkOS User Management does not currently offer a session management feature, this must instead be handled by the application. For illustration purposes we’ll be using a JSON Web Token (JWT) to store the authenticated user in a short lived cookie, though your approach may differ depending on the application's specific requirements.
Which seems to refer to this file in their example. Not sure if that affects the setup for Convex.
User Management – WorkOS Docs
Easy to use authentication APIs designed to provide a flexible, secure, and fast integration.
Custom Auth Integration | Convex Developer Hub
Convex can be integrated with any identity provider supporting the
User Management – WorkOS Docs
Easy to use authentication APIs designed to provide a flexible, secure, and fast integration.
GitHub
next-authkit-example/src/app/callback/route.ts at main · workos/nex...
Example application demonstrating how to authenticate users with AuthKit and the WorkOS Node SDK. - workos/next-authkit-example
6 Replies
Michal Srb
Michal Srb11mo ago
Hey @John, from cursory look, I think you'd have to initiate a JWT on the server: https://workos.com/docs/user-management/3-handle-the-user-session/issue-a-jwt Then pass that to your client and pass that to Convex via the Custom Auth Integration. Does that help? Any reason you can't use Clerk or Auth0?
User Management – WorkOS Docs
Easy to use authentication APIs designed to provide a flexible, secure, and fast integration.
John
JohnOP11mo ago
was mainly curious about workos since it says 1million free users going to just using clerk, the templates/doc and web dev cody yt videos were great references!
Abhishek
Abhishek11mo ago
@John if you find any solution do share it here . I am also transitioning from clerk auth to some other solution cause clerk auth is having too many bugs and their support is also slow. Thanks
Michal Srb
Michal Srb8mo ago
@John you might be able to use WorkOS through NextAuth: https://stack.convex.dev/nextauth
Convex with Auth.js (NextAuth)
Learn how to use Auth.js with your Next.js server and Convex backend to build a full-featured authentication system.
Matt Luo
Matt Luo6mo ago
@Michal Srb - When you say work with WorkOS through NextAuth, I think you are saying to use WorkOS as a provider. I don't think that's going to help many Convex projects because businesses don't typically store their employee user info in WorkOS. Can I request a feature so that WorkOS is an officially supported third-party authentication provider for a Convex project? In the meantime, I'll try to setup WorkOS through the Custom Auth Integration approach.
https://docs.convex.dev/auth/advanced/custom-auth
Custom Auth Integration | Convex Developer Hub
Note: This is an advanced feature! We recommend sticking with the
Matt Luo
Matt Luo6mo ago
Actually, let me do some more research before going so far as to request a feature for Convex's official WorkOS support.

Did you find this page helpful?