Skip to content

Commit f8e90f7

Browse files
committed
Documentation edits made through Mintlify web editor
1 parent 00e4bd3 commit f8e90f7

File tree

4 files changed

+113
-66
lines changed

4 files changed

+113
-66
lines changed

installation/authentication-setup/supabase-auth.mdx

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,58 @@ sidebarTitle: Overview
88
You can implement various types of auth:
99

1010
* Standard [Supabase Auth](https://supabase.com/docs/guides/auth)
11-
* JavaScript [example](https://github.com/powersync-ja/powersync-js/blob/58fd05937ec9ac993622666742f53200ee694585/demos/react-supabase-todolist/src/library/powersync/SupabaseConnector.ts#L87)
12-
* Dart/Flutter [example](https://github.com/powersync-ja/powersync.dart/blob/9ef224175c8969f5602c140bcec6dd8296c31260/demos/supabase-todolist/lib/powersync.dart#L38)
13-
* Kotlin [example](https://github.com/powersync-ja/powersync-kotlin/blob/4f60e2089745dda21b0d486c70f47adbbe24d289/connectors/supabase/src/commonMain/kotlin/com/powersync/connector/supabase/SupabaseConnector.kt#L75)
11+
12+
* JavaScript [example](https://github.com/powersync-ja/powersync-js/blob/58fd05937ec9ac993622666742f53200ee694585/demos/react-supabase-todolist/src/library/powersync/SupabaseConnector.ts#L87)
13+
14+
* Dart/Flutter [example](https://github.com/powersync-ja/powersync.dart/blob/9ef224175c8969f5602c140bcec6dd8296c31260/demos/supabase-todolist/lib/powersync.dart#L38)
15+
16+
* Kotlin [example](https://github.com/powersync-ja/powersync-kotlin/blob/4f60e2089745dda21b0d486c70f47adbbe24d289/connectors/supabase/src/commonMain/kotlin/com/powersync/connector/supabase/SupabaseConnector.kt#L75)
17+
1418
* Anonymous Sign-Ins
15-
* JavaScript [Example](https://github.com/powersync-ja/powersync-js/blob/58fd05937ec9ac993622666742f53200ee694585/demos/react-multi-client/src/library/SupabaseConnector.ts#L47)
19+
20+
* JavaScript [Example](https://github.com/powersync-ja/powersync-js/blob/58fd05937ec9ac993622666742f53200ee694585/demos/react-multi-client/src/library/SupabaseConnector.ts#L47)
21+
1622
* Fully custom auth
17-
* [Example](https://github.com/powersync-ja/powersync-jwks-example/)
23+
24+
* [Example](https://github.com/powersync-ja/powersync-jwks-example/)
25+
1826
* Experimental: We've also heard from the community that Supabase's newly released [support for external auth providers works](https://supabase.com/blog/third-party-auth-mfa-phone-send-hooks), but we don't have any examples for this yet.
1927

20-
To implement either **Supabase Auth** or **Anonymous Sign-Ins**, enable the "Use Supabase Auth" setting on the PowerSync instance, and provide your Supabase JWT Secret. Internally, this setting allows PowerSync to verify and use Supabase JWTs directly using HS256 and the provided secret.
28+
## Enabling Supabase Auth
29+
30+
To implement either **Supabase Auth** or **Anonymous Sign-Ins**, enable the relevant setting on the PowerSync instance, and provide your Supabase JWT Secret. Internally, this setting allows PowerSync to verify and use Supabase JWTs directly using HS256 and the provided secret.
31+
32+
### PowerSync Cloud instances:
33+
34+
1. In the PowerSync Dashboard, right-click on your instance to edit it.
35+
36+
2. Under the **"Client Auth"** tab, enable **"Use Supabase Auth"** and enter your Supabase **JWT Secret**:<Frame caption="PowerSync uses the secret to verify Supabase's JWTs.">
37+
![](/images/authentication/use-supabase-auth.png)
38+
</Frame>
39+
40+
3. Click **"Save and deploy"** to deploy the updates to your instance.
41+
42+
### Self-hosted instances:
43+
44+
This can be enabled via your [`config.yaml`](/self-hosting/installation/powersync-service-setup):
45+
46+
```yaml
47+
48+
client\_auth:
49+
&#x20; *# Enable this if using Supabase Auth*
50+
&#x20; supabase: true
51+
&#x20; supabase\_jwt\_secret: your-jwt-secret
52+
53+
```
54+
55+
## Rotating the JWT Secret
2156

22-
Enabling Supabase Auth is also [covered in the Supabase & PowerSync integration guide](/integration-guides/supabase-+-powersync#configuring-powersync).
57+
If you encounter authroziation errors, you may need to regenrate the JWT Secret. A common cause of this are Supabase projects that are restarted after being paused.
2358

2459
To rotate the secret, generate a new secret in the your Supabase project's API Settings:
2560

2661
<Frame>
27-
<img src="/images/authentication/supabase-jwt-secret.png"/>
62+
![](/images/authentication/supabase-jwt-secret.png)
2863
</Frame>
2964

30-
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](/installation/authentication-setup/custom).
65+
The Supabase user UUID will be available as `request.user_id()` in [Sync Rules](/usage/sync-rules). To use a different identifier as the user ID in sync rules (for example user email), use [Custom authentication](/installation/authentication-setup/custom).

self-hosting/installation/client-side-setup.mdx

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,21 @@ title: "Client-Side Setup"
55
We recommend splitting up your client-side implementation into four phases:
66

77
<CardGroup>
8-
<Card title="Generate development token" icon="key" href="/self-hosting/installation/client-side-setup#1-generate-development-token" horizontal/> <Card title="Run Diagnostics app" icon="bug" href="/self-hosting/installation/client-side-setup#2-run-the-diagnostics-app-using-a-development-token" horizontal/>
9-
<Card title="Use client SDK with token" icon="code" href="/self-hosting/installation/client-side-setup#3-use-the-client-sdk-with-development-token" horizontal/>
10-
<Card title="Implement authentication" icon="lock" href="/self-hosting/installation/client-side-setup#4-implement-authentication" horizontal/>
8+
<Card title="Generate development token" icon="key" href="/self-hosting/installation/client-side-setup#1-generate-development-token" horizontal />
9+
10+
<Card title="Run Diagnostics app" icon="bug" href="/self-hosting/installation/client-side-setup#2-run-the-diagnostics-app-using-a-development-token" horizontal />
11+
12+
<Card title="Use client SDK with token" icon="code" href="/self-hosting/installation/client-side-setup#3-use-the-client-sdk-with-development-token" horizontal />
13+
14+
<Card title="Implement authentication" icon="lock" href="/self-hosting/installation/client-side-setup#4-implement-authentication" horizontal />
1115
</CardGroup>
1216

13-
## 1\. Generate Development Token
17+
## 1. Generate Development Token
1418

1519
The recommended approach is to initially use a short-lived development token and then wire up production auth at a later stage.
1620

1721
1. Generate a temporary private/public key-pair (RS256) or shared key (HS256) for JWT signing and verification.
22+
1823
2. Add the key to your PowerSync Service configuration file, e.g.:
1924

2025
```yaml
@@ -31,10 +36,14 @@ client_auth:
3136
```
3237
3338
1. Generate a signed JWT. We have two options to get you started:
39+
3440
1. If you have a `.yaml` configuration file and HS256 key, we recommending using the `generate-token` script from the Test Client in the [powersync-service repo](https://github.com/powersync-ja/powersync-service/tree/main/test-client), as described here [Self-hosted Setup / Local Development](/installation/authentication-setup/development-tokens#self-hosted-setup-local-development). You need to clone this repo to use this option.
41+
3542
2. Alternatively:
36-
1. Save the private key into a `.env` file.
37-
2. Generate a JWT, loading the `.env` file and inputting a user UUID. See example script:
43+
44+
1. Save the private key into a `.env` file.
45+
46+
2. Generate a JWT, loading the `.env` file and inputting a user UUID. See example script:
3847

3948
```js
4049
import * as jose from 'jose';
@@ -63,7 +72,7 @@ const token = await new jose.SignJWT({})
6372
console.log(token);
6473
```
6574

66-
## 2\. Run the Diagnostics app using a development token
75+
## 2. Run the Diagnostics app using a development token
6776

6877
With the [Diagnostics web app](https://github.com/powersync-ja/powersync-js/tree/main/tools/diagnostics-app) you can quickly inspect a user's local database. By using this you can confirm that the PowerSync Service configuration and sync rules behave as expected without needing to set up authentication or app UI.
6978

@@ -78,18 +87,18 @@ Enter the generated token into the app's sign in screen.
7887
Enter your PowerSync Service endpoint (see the port number specified in your config file e.g. `http://localhost:8080`).
7988

8089
<Info>
81-
**Checkpoint:**
90+
**Checkpoint:**
8291

83-
Inspect your global bucket and synced table (from the [PowerSync Service Setup](/self-hosting/installation/powersync-service-setup) section) in the diagnostics app — these should match the sync rules you [defined previously](/self-hosting/installation/powersync-service-setup#1.sync-rules).
92+
Inspect your global bucket and synced table (from the [PowerSync Service Setup](/self-hosting/installation/powersync-service-setup) section) in the diagnostics app — these should match the sync rules you [defined previously](/self-hosting/installation/powersync-service-setup#1.sync-rules).
8493
</Info>
8594

86-
## 3\. Use the Client SDK with a development token
95+
## 3. Use the Client SDK with a development token
8796

8897
Install the PowerSync client SDK in your app. Refer to the client-side installation instructions here: [Client-Side Setup](/installation/client-side-setup)
8998

9099
Hardcode the development token you generated above in the `fetchCredentials` method, which you'll implement as part of [Integrate with your Backend](/installation/client-side-setup/integrating-with-your-backend)
91100

92-
## 4\. Implement authentication
101+
## 4. Implement authentication
93102

94103
Read about how authentication works in PowerSync here: [Authentication Setup](/installation/authentication-setup)
95104

@@ -105,7 +114,7 @@ Under `client_auth` in your config file, enable Supabase authentication:
105114
client_auth:
106115
# Enable this if using Supabase Auth
107116
supabase: true
108-
supabase_jwt_secret: [secret]
117+
supabase_jwt_secret: your-secret
109118
```
110119

111120
For more details, see [Supabase Auth](/installation/authentication-setup/supabase-auth).
@@ -115,6 +124,7 @@ For more details, see [Supabase Auth](/installation/authentication-setup/supabas
115124
Under `client_auth` in your config file, add your Firebase JWKS URI and audience.
116125

117126
* JWKS URI: [https://www.googleapis.com/service\_accounts/v1/jwk/[email protected]](https://www.googleapis.com/service%5Faccounts/v1/jwk/[email protected])
127+
118128
* JWT Audience: Your Firebase project ID
119129

120130
```yaml
@@ -135,7 +145,7 @@ For more details, see [Firebase Auth](/installation/authentication-setup/firebas
135145

136146
Refer to: [Custom](/installation/authentication-setup/custom)
137147

138-
PowerSync supports both RS256 and HS256\. Insert your auth details into your configuration file:
148+
PowerSync supports both RS256 and HS256. Insert your auth details into your configuration file:
139149

140150
```yaml
141151
# config.yaml
@@ -154,4 +164,4 @@ client_auth:
154164
# kid: '${PS_JWK_KID}'
155165
156166
audience: ['powersync-dev', 'powersync']
157-
```
167+
```

self-hosting/installation/powersync-service-setup.mdx

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ After configuring your Postgres database for PowerSync, you'll setup your [Power
88
This entails:
99

1010
1. Configuring MongoDB (if required)
11+
1112
2. Defining your PowerSync config
13+
1214
1. Defining connections to Postgres and MongoDB
15+
1316
2. Defining your [Sync Rules](/usage/sync-rules)
17+
1418
3. Defining your auth method
1519

1620
Examples of the above can be found in our demo application [here](https://github.com/powersync-ja/self-host-demo/tree/main/config). Below we go through these in more detail.
@@ -28,6 +32,7 @@ mongosh "mongodb+srv://powersync.abcdef.mongodb.net/" --apiVersion 1 --username
2832
```
2933

3034
If you are rolling your own Docker environment, you can include this init script in your docker-compose file to configure a replica set as once-off operation:
35+
3136
```yaml
3237
# Initializes the MongoDB replica set. This service will not usually be actively running
3338
mongo-rs-init:
@@ -46,26 +51,20 @@ If you are rolling your own Docker environment, you can include this init script
4651
The PowerSync Service is configured using key/value pairs in a config file, and supports the following configuration methods:
4752
4853
1. Inject config as an environment variable (which contains the base64 encoding of a config file)
54+
4955
2. Use a config file mounted on a volume
56+
5057
3. Specify the config as a command line parameter (again base64 encoded)
5158
5259
Both YAML and JSON config files are supported, and you can see examples of the above configuration methods in our demo app's [docker-compose](https://github.com/powersync-ja/self-host-demo/blob/d61cea4f1e0cc860599e897909f11fb54420c3e6/docker-compose.yaml#L46) file.
5360
5461
A detailed `config.yaml` example with additional comments can be found here:
55-
<Card
56-
title="self-host-demo/config/powersync.yaml at main · powersync-ja/self-host-demoGitHub"
57-
icon="github"
58-
href="https://github.com/powersync-ja/self-host-demo/blob/main/config/powersync.yaml"
59-
horizontal
60-
/>
62+
63+
<Card title="self-host-demo/config/powersync.yaml at main · powersync-ja/self-host-demoGitHub" icon="github" href="https://github.com/powersync-ja/self-host-demo/blob/main/config/powersync.yaml" horizontal />
6164

6265
The config file schema is also available here:
63-
<Card
64-
title="self-host-demo/schema/schema.json at main · powersync-ja/self-host-demoGitHub"
65-
icon="github"
66-
href="https://github.com/powersync-ja/self-host-demo/blob/main/schema/schema.json"
67-
horizontal
68-
/>
66+
67+
<Card title="self-host-demo/schema/schema.json at main · powersync-ja/self-host-demoGitHub" icon="github" href="https://github.com/powersync-ja/self-host-demo/blob/main/schema/schema.json" horizontal />
6968

7069
Below is a skeleton config file that you can copy/paste and edit locally:
7170

@@ -113,7 +112,7 @@ sync_rules:
113112
client_auth:
114113
# Enable this if using Supabase Auth
115114
# supabase: true
116-
# supabase_jwt_secret: [secret]
115+
# supabase_jwt_secret: your-secret
117116
118117
# JWKS URIs can be specified here.
119118
jwks_uri: http://demo-backend:6060/api/auth/keys
@@ -132,11 +131,11 @@ client_auth:
132131
Specify the connection to Postgres in the `replication` section. Retrieving your database connection string / individual parameters differs by database hosting provider. See [Database Connection](/self-hosting/appendix/database-connection) for further details.
133132

134133
<Info>
135-
If you are using hosted Supabase, you will need to enable IPv6 for Docker as per [https://docs.docker.com/config/daemon/ipv6/](https://docs.docker.com/config/daemon/ipv6/)
134+
If you are using hosted Supabase, you will need to enable IPv6 for Docker as per [https://docs.docker.com/config/daemon/ipv6/](https://docs.docker.com/config/daemon/ipv6/)
136135

137-
If your host OS does not support Docker IPv6 e.g. macOS, you will need to run Supabase locally.
136+
If your host OS does not support Docker IPv6 e.g. macOS, you will need to run Supabase locally.
138137

139-
This is because Supabase only allows direct database connections over IPv6 — PowerSync cannot connect using the connection pooler.
138+
This is because Supabase only allows direct database connections over IPv6 — PowerSync cannot connect using the connection pooler.
140139
</Info>
141140

142141
Specify the connection to MongoDB in the `storage` section.
@@ -150,12 +149,8 @@ Using `!env [variable name]` will substitute the value of the environment variab
150149
Only environment variables with names starting with `PS_` can be substituted.
151150

152151
See examples here:
153-
<Card
154-
title="self-host-demo/config/powersync.yaml at main · powersync-ja/self-host-demoGitHub"
155-
icon="github"
156-
href="https://github.com/powersync-ja/self-host-demo/blob/main/config/powersync.yaml"
157-
horizontal
158-
/>
152+
153+
<Card title="self-host-demo/config/powersync.yaml at main · powersync-ja/self-host-demoGitHub" icon="github" href="https://github.com/powersync-ja/self-host-demo/blob/main/config/powersync.yaml" horizontal />
159154

160155
### Sync Rules
161156

@@ -195,15 +190,15 @@ For more information about sync rules see:
195190
[Sync Rules](/usage/sync-rules)
196191

197192
<Info>
198-
**Checkpoint**
193+
**Checkpoint**
199194

200-
To verify that your sync rules are functioning correctly, inspect the contents of your sync bucket in MongoDB.
195+
To verify that your sync rules are functioning correctly, inspect the contents of your sync bucket in MongoDB.
201196

202-
If you are running MongoDB in Docker, run the following:
197+
If you are running MongoDB in Docker, run the following:
203198

204-
```bash
205-
docker exec -it {MongoDB container name} mongosh "mongodb://{MongoDB service host}/{MongoDB database name}" --eval "db.bucket_data.find().pretty()"
206-
# Example
207-
docker exec -it self-host-demo-mongo-1 mongosh "mongodb://localhost:27017/powersync_demo" --eval "db.bucket_data.find().pretty()"
208-
```
209-
</Info>
199+
```bash
200+
docker exec -it {MongoDB container name} mongosh "mongodb://{MongoDB service host}/{MongoDB database name}" --eval "db.bucket_data.find().pretty()"
201+
# Example
202+
docker exec -it self-host-demo-mongo-1 mongosh "mongodb://localhost:27017/powersync_demo" --eval "db.bucket_data.find().pretty()"
203+
```
204+
</Info>
Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
1+
1. Copy the database connection details from Supabase:<Frame caption="It is important to uncheck this checkbox">
2+
<img src="/images/integration-3.png" />
3+
</Frame>
14

2-
1. Copy the database connection details from Supabase:
3-
* In your Supabase dashboard, navigate to **"Project Settings"** \-> **"Database" -> "Connection string**" and select the "URI" tab.
4-
* Uncheck the "**Display connection pooler**" checkbox. PowerSync needs to connect to the database directly and cannot use the pooler.
5-
<Frame caption="It is important to uncheck this checkbox">
6-
<img src="/images/integration-3.png"/>
7-
</Frame>
85
* Copy the connection string. The hostname should be `db.<PROJECT-ID>.supabase.co`, and not, for example, `aws-0-us-west-1.pooler.supabase.com`.
6+
97
* Paste this URI in PowerSync instance **URI** field.
8+
109
* Enter the **Password** for the `postgres` user in your Supabase database.
11-
* Supabase also [refers to this password](https://supabase.com/docs/guides/database/managing-passwords) as the _database password_ or _project password_.
10+
11+
* Supabase also [refers to this password](https://supabase.com/docs/guides/database/managing-passwords) as the *database password* or *project password*.
12+
1213
* PowerSync has the Supabase CA certificate pre-configured — `verify-full` SSL mode can be used directly, without any custom certificates.
14+
15+
- In your Supabase dashboard, navigate to **"Project Settings"** -> **"Database" -> "Connection string**" and select the "URI" tab.
16+
17+
- Uncheck the "**Display connection pooler**" checkbox. PowerSync needs to connect to the database directly and cannot use the pooler.
18+
1319
2. Click **"Test Connection"** and fix any errors.
14-
3. Under the **"Client Auth"** tab, enable **"Use Supabase Auth"** and enter your Supabase **JWT Secret**:
15-
<Frame caption="PowerSync uses the secret to verify Supabase's JWTs.">
16-
<img src="/images/authentication/use-supabase-auth.png"/>
17-
</Frame>
18-
4. Click **"Save".**
20+
21+
3. Under the **"Client Auth"** tab, enable **"Use Supabase Auth"** and enter your Supabase **JWT Secret**:<Frame caption="PowerSync uses the secret to verify Supabase's JWTs.">
22+
![](/images/authentication/use-supabase-auth.png)
23+
</Frame>
24+
25+
4. Click **"Save and deploy"** to deploy the updates to your instance.
1926

2027
PowerSync deploys and configures an isolated cloud environment for you, which will take a few minutes to complete.

0 commit comments

Comments
 (0)