> ## Documentation Index
> Fetch the complete documentation index at: https://docs.powersync.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Stytch + Supabase

> Set up Stytch authentication with Supabase for PowerSync.

## Consumer Authentication

See this community project for detailed setup instructions:

<Card title="GitHub - guillempuche/localfirst_react_server" icon="github" href="https://github.com/guillempuche/localfirst\_react\_server](https://github.com/guillempuche/localfirst_react_server" horizontal />

## B2B SaaS Authentication

The high-level approach is:

* Users authenticate via [Stytch](https://stytch.com/)
* 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 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](https://dashboard.powersync.com/):

<Frame>
  <img src="https://mintcdn.com/powersync/3jDKXjn3LiU68TOx/images/usage-20.avif?fit=max&auto=format&n=3jDKXjn3LiU68TOx&q=85&s=ed05fcc242d3c2bd66b342c960029a00" width="800" height="528" data-path="images/usage-20.avif" />
</Frame>

Reach out to us directly on our [Discord server](https://discord.gg/powersync) if you have any issues with setting up auth.
