Skip to content

Improve Documentation Structure for Better LLM Indexing #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 33 additions & 9 deletions installation/authentication-setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,59 @@ title: "Authentication Setup"
sidebarTitle: Overview
---

PowerSync clients (i.e. apps used by your users that embed the PowerSync Client SDK) authenticate against the server-side [PowerSync Service](/architecture/powersync-service) using [JWTs](https://jwt.io/) (signed tokens) that are generated by your application backend.
# PowerSync Authentication Overview

PowerSync uses JSON Web Tokens (JWTs) for secure client authentication. These tokens are generated by your application backend and used by PowerSync clients to authenticate against the PowerSync Service.

## Initial Architecture

Before implementing PowerSync, a typical application architecture might look like this:

Before using PowerSync, an application's existing architecture may look like this:
<Frame>
<img src="/images/powersync-docs-architecture-diagram-001 (1).png"/>
</Frame>

The [PowerSync Service](/architecture/powersync-service) uses database native credentials and authenticates directly against the [backend database](/installation/database-setup) using the configured credentials:
## PowerSync Service Authentication

The PowerSync Service maintains a direct connection to your backend database using native credentials:

<Frame>
<img src="/images/powersync-docs-architecture-diagram-002 (2).png"/>
</Frame>

When the PowerSync client SDK is included in an app project, it uses [existing app-to-backend](/installation/app-backend-setup) authentication to [retrieve a JSON Web Token (JWT)](/installation/authentication-setup):
## Client Authentication Flow

### Step 1: JWT Retrieval
When integrated into your app, the PowerSync client SDK uses your existing app-to-backend authentication to obtain a JSON Web Token:

<Frame>
<img src="/images/powersync-docs-architecture-diagram-004 (2).png"/>
</Frame>

The PowerSync client SDK uses the retrieved JWT to authenticate directly against the PowerSync Service:
### Step 2: PowerSync Service Connection
The PowerSync client SDK then uses this JWT to establish a secure connection with the PowerSync Service:

<Frame>
<img src="/images/powersync-docs-architecture-diagram-005 (2).png"/>
</Frame>

Users are not persisted in PowerSync, and there is no server-to-server communication used for client authentication.
<Note>
PowerSync does not persist user information, and there is no server-to-server communication for client authentication.
</Note>

## Authentication Options

Some authentication providers already generate JWTs for users which PowerSync can verify directly — see the documentation for individual providers (e.g. [Supabase Auth](/installation/authentication-setup/supabase-auth), [Firebase Auth](/installation/authentication-setup/firebase-auth))
### Pre-configured Providers
Some authentication providers generate JWTs that PowerSync can verify directly:
- [Supabase Auth](/installation/authentication-setup/supabase-auth)
- [Firebase Auth](/installation/authentication-setup/firebase-auth)

For others, some backend code must be added to your application backend to generate the JWTs needed for PowerSync — see [Custom](/installation/authentication-setup/custom) authentication.
### Custom Authentication
For other authentication systems, you'll need to add JWT generation code to your backend. See our [Custom](/installation/authentication-setup/custom) authentication guide for details.

For a quick way to get up and running during development, you can generate [Development Tokens](/installation/authentication-setup/development-tokens) directly from the [PowerSync Dashboard](/usage/tools/powersync-dashboard) (PowerSync Cloud) or locally with a self-hosted setup.
### Development Tokens
<Tip>
For quick development and testing, you can generate [Development Tokens](/installation/authentication-setup/development-tokens) through the:
- [PowerSync Dashboard](/usage/tools/powersync-dashboard) (PowerSync Cloud)
- Local setup (self-hosted installations)
</Tip>
Loading
Loading