Skip to content

Commit 43bdc7f

Browse files
authored
Merge branch 'docs' into postgres-bucket-storage
2 parents 20ff3e4 + c285c73 commit 43bdc7f

File tree

3 files changed

+42
-34
lines changed

3 files changed

+42
-34
lines changed

client-sdk-references/react-native-and-expo/react-native-web-support.mdx

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,34 @@ title: "React Native Web Support"
77
Support for React Native Web is available since versions 1.12.1 of the [PowerSync React Native SDK](/client-sdk-references/react-native-and-expo) and 1.8.0 if the [JavaScript/Web SDK](/client-sdk-references/javascript-web), and is currently in a **beta** release.
88

99
A demo app showcasing this functionality is available here:
10-
<Card
11-
title="powersync-js/demos/react-native-web-supabase-todolist"
12-
icon="github"
13-
href="https://github.com/powersync-ja/powersync-js/tree/main/demos/react-native-web-supabase-todolist"
14-
horizontal
15-
/>
10+
11+
<Card title="powersync-js/demos/react-native-web-supabase-todolist" icon="github" href="https://github.com/powersync-ja/powersync-js/tree/main/demos/react-native-web-supabase-todolist" horizontal />
1612

1713
## Configuring PowerSync in your React Native for Web project
1814

1915
To ensure that PowerSync features are fully supported in your React Native Web project, follow the below steps. This documentation covers necessary web worker configurations, database instantiation, and multi-platform implementations.
2016

21-
### 1\. Install Web SDK
17+
### 1. Install Web SDK
2218

2319
The [PowerSync Web SDK](/client-sdk-references/javascript-web), alongside the [PowerSync React Native SDK](/client-sdk-references/react-native-and-expo), is required for Web support.
2420

2521
See installation instructions [here](https://www.npmjs.com/package/@powersync/web).
2622

27-
### 2\. Configure Web Workers
23+
### 2. Configure Web Workers
2824

2925
For React Native for Web, workers need to be configured when instantiating `PowerSyncDatabase`. An example of this is available [here](https://github.com/powersync-ja/powersync-js/blob/main/demos/react-native-web-supabase-todolist/library/powersync/system.ts).
3026

3127
To do this, copy the contents of `node_modules/@powersync/web/dist` to the root of your project (typically in the `public `directory). To make it easier to manage these files in the `public` directory, it is recommended to place the contents in a nested directory like `@powersync`.
3228

33-
You can run the following bash command to automate the copying process. It will create copy the contents to `/public/@powersync`.
29+
The [`@powersync/web`](https://github.com/powersync-ja/powersync-js/tree/main/packages/web) package includes a CLI utility which can copy the required assets to the `public` directory (configurable with the `--output` option).
3430

3531
```bash
36-
mkdir -p public/@powersync && cp -r node_modules/@powersync/web/dist/* public/@powersync/
32+
# Places assets into public/@powersync by default. Override with `--output path/from_current_working_dir`.
33+
npx powersync-web copy-assets
34+
# or pnpm powersync-web copy-assets
3735
```
3836

39-
### 3\. Instantiate Web Workers
37+
### 3. Instantiate Web Workers
4038

4139
The example below demonstrates how to instantiate the workers (PowerSync requires a database and a sync worker) when instantiating `PowerSyncDatabase`. You can either specify a path to the worker (they are available in the `worker` directory of the `dist` contents), or provide a factory function to create the worker.
4240

@@ -82,7 +80,7 @@ this.powersync = new PowerSyncDatabaseWeb({
8280

8381
This `PowerSyncDatabaseWeb` database will be used alongside the native `PowerSyncDatabase` to support platform-specific implementations. See the [Instantiating PowerSync](/client-sdk-references/react-native-and-expo/react-native-web-support#implementations) section below for more details.
8482

85-
### 4\. Enable multiple platforms
83+
### 4. Enable multiple platforms
8684

8785
To target both mobile and web platforms, you need to adjust the Metro configuration and handle platform-specific libraries accordingly.
8886

@@ -192,6 +190,7 @@ export async function prompt(
192190
```
193191

194192
Which can then be used agnostically in a component.
193+
195194
```js
196195
import { Button } from 'react-native';
197196
import { prompt } from 'util/prompt';
@@ -214,15 +213,17 @@ import { prompt } from 'util/prompt';
214213
}}
215214
/>;
216215
```
217-
### 5\. Configure UMD target
216+
217+
### 5. Configure UMD target
218218

219219
React Native Web requires the UMD target of `@powersync/web` (available at `@powersync/web/umd`). To fully support this target version, configure the following in your project:
220220

221221
1. Add `config.resolver.unstable_enablePackageExports = true;` to your `metro.config.js` file.
222+
222223
2. TypeScript projects: In the `tsconfig.json` file specify the `moduleResolution` to be `Bundler`.
223224

224225
```json
225226
"compilerOptions": {
226227
"moduleResolution": "Bundler"
227228
}
228-
```
229+
```
180 KB
Loading
Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,38 @@
1-
1. In your Supabase Dashboard, click **Connect** in the top bar:
2-
3-
<Frame>
4-
<img src="/images/installation/supabase-connect-database.png" />
5-
</Frame>
1+
1. From your Supabase Dashboard, select **Connect** in the top navigation bar:
62

7-
* Under **Direct connection**, 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`.
8-
9-
<Frame>
10-
<img src="/images/installation/supabase-connection-string.png" />
11-
</Frame>
3+
<Frame>
4+
<img src="/images/installation/supabase-connect-database.png" />
5+
</Frame>
6+
7+
* In the **Direct connection** section, copy the complete connection string (including the `[YOUR-PASSWORD]` placeholder)
8+
9+
<Frame>
10+
<img src="/images/installation/supabase-connection-string.png" />
11+
</Frame>
1212

13-
* Paste this URI in PowerSync instance **URI** field.
13+
* Paste the connection string into the PowerSync instance **URI** field. PowerSync will automatically parse this URI to populate the connection details.
1414

15-
* Enter the **Password** for the `postgres` user in your Supabase database.
15+
* For the **Password** field, enter your database's `postgres` user password (this is your database/project password, not your Supabase account password). Need help? Check Supabase's guide on [managing database passwords](https://supabase.com/docs/guides/database/managing-passwords).
1616

17-
* Supabase also [refers to this password](https://supabase.com/docs/guides/database/managing-passwords) as the *database password* or *project password*.
17+
* Note: PowerSync includes Supabase's CA certificate by default, so you can use `verify-full` SSL mode without additional configuration.
18+
19+
Your connection settings should look similar to this:
20+
21+
<Frame>
22+
<img src="/images/integration-guides/powersync-supabase-connection.png" />
23+
</Frame>
1824

19-
* PowerSync has the Supabase CA certificate pre-configured — `verify-full` SSL mode can be used directly, without any custom certificates.
25+
2. Verify your setup by clicking **Test Connection** and resolve any errors.
2026

21-
2. Click **Test Connection** and fix any errors.
27+
3. Configure authentication:
28+
* Navigate to the **Client Auth** tab
29+
* Enable **Use Supabase Auth**
30+
* Enter your Supabase **JWT Secret**
2231

23-
3. Under the **Client Auth** tab, enable **Use Supabase Auth** and enter your Supabase **JWT Secret**:
24-
25-
<Frame caption="PowerSync uses the secret to verify Supabase's JWTs">
32+
<Frame caption="PowerSync will use this secret to validate Supabase JWTs">
2633
<img src="/images/authentication/use-supabase-auth.png" />
2734
</Frame>
2835

29-
4. Click **Save and deploy** to deploy the updates to your instance.
36+
4. Click **Save and deploy** to apply your changes.
3037

31-
PowerSync deploys and configures an isolated cloud environment for you, which will take a few minutes to complete.
38+
PowerSync will now create an isolated cloud environment for your instance. This process typically takes a few minutes.

0 commit comments

Comments
 (0)