Skip to main content

Client Authentication

PowerSync clients (i.e. apps used by your users that embed the PowerSync client SDK) authenticate against the server-side PowerSync Service using JWTs (signed tokens).
When you call connect() on the client-side PowerSync database, you pass the URL of your PowerSync Service instance and an authenticator. The authenticator’s resolveCredentials() method returns the JWT, and the client SDK calls it whenever it needs a token. See When resolveCredentials() is Called for the specific conditions and timing.

Client Authentication Options

Development & Testing

For a quick way to get up and running during development, you can generate Development Tokens directly from the PowerSync Dashboard (PowerSync Cloud) or locally with a self-hosted setup.

Production

Development tokens are generated manually for one user ID and expire after 12 hours. In production, your authenticator must return a JWT for the user who is signed in to your app, without manual steps. How you get that JWT depends on your authentication provider: Use Existing JWT from Auth Provider: Some authentication providers already generate JWTs for users which PowerSync can verify directly — see Common Authentication Providers below. In this scenario, your authenticator’s resolveCredentials() can return the existing JWT from your client-side state. Custom Auth Integration: Generate JWTs: For others, some backend code must be added to your application backend to generate the JWTs needed for PowerSync — see Custom Authentication. In this scenario, your authenticator’s resolveCredentials() should make an API call to your backend application to obtain a JWT. Cache that JWT in your authenticator, because the client SDK can call resolveCredentials() often. See Cache the Token in Your Authenticator for an example in each SDK.

Common Authentication Providers

PowerSync supports JWT-based authentication from various providers. The table below shows commonly used authentication providers, their JWKS URLs, and any specific configuration requirements.
Scroll the table horizontally.