Thanks for posting!
Yes - there are many ways to integrate with Stytch, and you can definitely still use the JS SDK to manage cookies even if you’re using some backend Stytch API functionality, or just using your own backend to hook into your DB based on events that occur on your frontend.
A few high level questions to help us better understand what the best path might look like here:
- What Stytch Member information do you need to store in your own database?
- Are you able to provide a bit more context on the reason you’d like to check Stytch Member data against your own DB rather than on the Stytch Member object itself, and what sort of controls you’re looking to put in place that leverage your own database?
- Would it be possible to just link the identifiers, e.g. store the Stytch
organization_id in your own database, and the identifier for your own database on the Stytch User object (in Member metadata), or do you need access to additional Stytch Member data in your own DB without hitting Stytch servers (e.g. calling our Get Member endpoint with the stored identifier)?
you don’t want a user self-onboarding to an Org via discovery only to then hit errors because the database hasn’t updated yet
Can you describe the failure case a bit more here, and what you’d like to verify against your own database before allowing a Discovery flow login? Are you looking to only allow invited users to join Organizations, or something else?
The general mechanism for controlling how a member can join, and who can join is with Organization authentication settings.
For instance, if you would like to disallow JIT provisioning and only allow invited members to join, you might:
- Only invite Members via invite Email Magic Links, adding the Member data to your own internal database when you invite them
If you do want to allow email JIT provisioning during Discovery logins, then you may want do something like:
RESTRICTED, allowing Members to be created and join Organizations without them being explicitly invited or already existing in your database,
- Add these Members to your own database once they’re created by making calls to your backend API when the relevant actions have occurred on the frontend (for instance, on
discover.intermediateSessions.exchange() calls during a Discovery flow).
How do customers usually go about using the Stytch Dashboard without getting into an inconsistent state with their DB and causing bugs?
We don’t currently provide any hooks for Dashboard actions similar to our frontend JS SDK hooks, so there isn’t a great way to automatically hook into such actions.
If you expect to be performing Member management in your Stytch Dashboard and need to sync those changes, the best way to do this may be to have your own backend run a cron job or similar on some cadence to keep the two in sync. That said, this likely depends on exactly what kind of data you need to keep in sync, and at what point this will be checked by your application.