Skip to main content
You can implement various types of auth:

Supabase JWT Signing Keys

Supabase supports two types of JWT signing keys:
TypeAlgorithmDescription
Legacy JWT signing keysHS256 (symmetric)Uses a shared secret to sign and verify tokens. This is the original method.
New JWT signing keysRS256 (asymmetric)Uses public/private key pairs. Supabase signs tokens with a private key, and PowerSync verifies them using a public key fetched via JWKS.
PowerSync supports both methods. Which configuration you need depends on your Supabase project’s JWT settings and your PowerSync deployment type.
To check which signing keys your Supabase project uses, go to Project Settings > JWT in your Supabase Dashboard.

PowerSync Cloud

When using PowerSync Cloud with a Supabase-hosted database, PowerSync can auto-detect your Supabase project from the database connection string and configure authentication automatically.

Self-Hosted PowerSync

For self-hosted PowerSync instances, configure authentication in your config.yaml.

Migrating from Legacy to New JWT Signing Keys

If you’re migrating your Supabase project from legacy JWT signing keys to the new asymmetric keys:

Step 1: Complete the Supabase Migration

Follow all steps in Supabase’s JWT Signing Keys migration guide, including the “Rotate to asymmetric JWTs” step.
The migration is not complete until you complete the “Rotate to asymmetric JWTs” step in Supabase. Skipping this step will cause authentication failures.

Step 2: Update PowerSync Configuration

For PowerSync Cloud and self-hosted with standard Supabase connections:
  • No changes required, PowerSync auto-detects and uses the new JWKS endpoint.
  • If you previously provided a legacy JWT secret, you can remove it (it’s no longer needed).
For manual JWKS configurations:
  • Ensure your jwks_uri points to your Supabase JWKS endpoint.
  • Verify the authenticated audience is configured.

Step 3: Clear Cached Tokens

Have all users sign out and sign back in. This ensures they receive new tokens signed with the asymmetric keys.

Troubleshooting

PSYNC_S2101: Could not find an appropriate key in the keystore

This error indicates PowerSync cannot verify the JWT signature. Common causes:
CauseSolution
Incomplete Supabase migrationComplete the “Rotate to asymmetric JWTs” step in Supabase’s migration guide.
Cached tokensHave users sign out and sign back in to get fresh tokens.
Non-standard connection stringPowerSync couldn’t auto-detect your Supabase project. Use manual JWKS configuration.
Wrong JWT secretFor legacy keys, verify the JWT secret matches your Supabase project settings.

PSYNC_S2105: JWT payload is missing a required claim “aud”

This error occurs when using manual JWKS configuration without specifying an audience. Add authenticated to your audience configuration.

Auto-detection not working

If PowerSync logs this warning:
Supabase Auth is enabled, but no Supabase connection string found. Skipping Supabase JWKS URL configuration.
This means PowerSync couldn’t detect your Supabase project from the database connection string. Use manual JWKS configuration instead.

Sync Rules

The Supabase user UUID will be available as request.user_id() in Sync Rules. To use a different identifier as the user ID in Sync Rules (for example user email), use Custom authentication.