Stytch + Supabase
PowerSync is compatible with both Consumer and B2B SaaS Stytch project types when using Stytch for auth with Supabase projects.
Consumer Authentication
See this community project for detailed setup instructions: https://github.com/guillempuche/localfirst_react_server
B2B SaaS Authentication
The high-level approach is:
Users authenticate via Stytch
Extract the user and org IDs from the Stytch JWT
Generate a Supabase JWT by calling a Supabase Edge Function that uses the Supabase JWT Secret for signing a new JWT
Set the KID in the JWT header
You can obtain this from any other Supabase JWT by - this value is static, even across DB upgrades.
Set the AUD field to
authenticated
Set the SUB field in the JWT payload to the user ID
Pass this new JWT into your PowerSync
fetchCredentials
function
Use the below settings in your PowerSync dashboard:
Reach out to us directly on our discord server if you have any issues setting up auth.
Last updated