Consumer Authentication
See this community project for detailed setup instructions: https://github.com/guillempuche/localfirst_react_serverB2B 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 extracting the KID value from the header — this value is static, even across database upgrades.
- Set the
AUD
field toauthenticated
- Set the
SUB
field in the JWT payload to the user ID
- Set the
- Pass this new JWT into your PowerSync
fetchCredentials
function
