diff --git a/installation/database-connection.mdx b/installation/database-connection.mdx index fc84e80a..cde168ce 100644 --- a/installation/database-connection.mdx +++ b/installation/database-connection.mdx @@ -3,17 +3,12 @@ title: "Database Connection" description: "Connect a PowerSync Cloud instance to your backend database." --- -## Create a PowerSync Instance +import CreateCloudInstance from '/snippets/create-cloud-instance.mdx'; +import SupabaseConnection from '/snippets/supabase-database-connection.mdx'; -1. In the [PowerSync Dashboard](/usage/tools/powersync-dashboard) project tree (PowerSync Cloud), click on "**Create new instance**": +## Create a PowerSync Cloud Instance - - - - -1. Give your instance a name, such as "Todolist Testing". -2. Under the "**General**" tab, you can change the default cloud region from "US" to "EU", "JP" (Japan), or "AU" (Australia) if desired (more cloud regions are available, [contact us](/resources/contact-us) if you need a different region). -3. Under the **"DB Connections"** tab, click on the **+** icon. + Each provider has their quirks when it comes to specifying connection details, so we have documented provider-specific instructions below. @@ -22,37 +17,17 @@ Each provider has their quirks when it comes to specifying connection details, s Select your Postgres hosting provider for steps to connect your Postgres database to the newly created PowerSync instance: -1. Get your connection details from Supabase: -* In your Supabase dashboard, navigate to **"Project Settings"** \-> **"Database" -> "Connection string**" and select the "URI" tab. -* Uncheck the "**Display connection pooler**" checkbox. PowerSync needs to connect to the database directly and cannot use the pooler. - - - -* Copy the connection string. The hostname should be `db..supabase.co`, and not, for example, `aws-0-us-west-1.pooler.supabase.com`. -* Paste this URI into the connection URI field. -* Enter the password for the `postgres` user in your Supabase database - * Supabase also [refers to this password](https://supabase.com/docs/guides/database/managing-passwords) as the _database password_ or _project password_. -* PowerSync has the Supabase CA certificate pre-configured — `verify-full` SSL mode can be used directly, without any custom certificates. -* If you want to query your database via the PowerSync dashboard, enable "_Allow querying in the editor?_". -1. Click **"Test Connection"** and fix any errors. -2. Under the **"Client Auth"** tab, enable **"Use Supabase Auth".** -3. Click **"Save".** - - -The "Supabase Auth" setting no longer works for Supabase projects created after 25 November 2024. While we are working with Supabase on a fix, please apply this workaround: https://releases.powersync.com/announcements/important-notice-for-supabase-users-using-supabase-jwts - + -PowerSync deploys and configures an isolated cloud environment for you, which can take a few minutes to complete. - -### Troubleshooting + ### Troubleshooting -Supabase is configured with a maximum of 4 logical replication slots, with one often used for Supabase Realtime. + Supabase is configured with a maximum of 4 logical replication slots, with one often used for Supabase Realtime. -It is therefore easy to run out of replication slots, resulting in an error such as "All replication slots are in use" when deploying. To resolve this, delete inactive replication slots by running this query: + It is therefore easy to run out of replication slots, resulting in an error such as "All replication slots are in use" when deploying. To resolve this, delete inactive replication slots by running this query: -```sql -select slot_name, pg_drop_replication_slot(slot_name) from pg_replication_slots where active = false; -``` + ```sql + select slot_name, pg_drop_replication_slot(slot_name) from pg_replication_slots where active = false; + ``` 1. [Locate the connection details from RDS](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER%5FConnectToPostgreSQLInstance.html): diff --git a/integration-guides/flutterflow-+-powersync.mdx b/integration-guides/flutterflow-+-powersync.mdx index 2ceedf33..29784a56 100644 --- a/integration-guides/flutterflow-+-powersync.mdx +++ b/integration-guides/flutterflow-+-powersync.mdx @@ -4,6 +4,9 @@ description: "Integration guide for creating offline-first apps with FlutterFlow sidebarTitle: Overview --- +import CreateCloudInstance from '/snippets/create-cloud-instance.mdx'; +import SupabaseConnection from '/snippets/supabase-database-connection.mdx'; + @@ -74,37 +77,11 @@ create publication powersync for table public.lists; ## Configure PowerSync -### Connect PowerSync to Your Supabase - -1. In the [PowerSync dashboard](/usage/tools/powersync-dashboard) Project tree, click on "**Create new instance**": - - - - - -1. Give your instance a name, such as "Supabase Testing". -2. Under the "**General**" tab, you can change the default cloud region from US to EU, JP (Japan), or AU (Australia) if desired (more cloud regions are available, [contact us](/resources/contact-us) if you need a different region). -3. Under the "DB Connections" tab, click on the + icon. -4. Now we get the connection details from Supabase: - * In your Supabase dashboard, navigate to **"Project Settings"** \-> **"Database" -> "Connection string**" and select the "URI" tab. - * Uncheck the "**Display connection pooler**" checkbox. PowerSync needs to connect to the database directly and cannot use the pooler. - - - -It is important to uncheck this checkbox - * Copy the connection string. The hostname should be `db..supabase.co`, and not, for example, `aws-0-us-west-1.pooler.supabase.com`. - * Paste this URI in PowerSync the instance **URI** field. - * Enter the password for the `postgres` user in your Supabase database: (Supabase also [refers to this password](https://supabase.com/docs/guides/database/managing-passwords) as the _database password_ or _project password_). - * PowerSync has the Supabase CA certificate pre-configured — `verify-full` SSL mode can be used directly, without any custom certificates. -1. Click **"Test Connection"** and fix any errors. -2. Under the **"Client Auth"** tab, enable **"Use Supabase Auth".** -3. Click **"Save".** +### Create a PowerSync Cloud Instance + - -The "Supabase Auth" setting no longer works for Supabase projects created after 25 November 2024. While we are working with Supabase on a fix, please apply this workaround: https://releases.powersync.com/announcements/important-notice-for-supabase-users-using-supabase-jwts - - -PowerSync deploys and configures an isolated cloud environment for you, which will take a few minutes to complete. +### Connect PowerSync to Your Supabase + ### Configure Sync Rules @@ -676,19 +653,18 @@ Below is a list of known issues and limitations. 1. It's not currently possible to use the FlutterFlow Web Editor to test your app due to limitations with FlutterFlow. 2. When trying to compile any of the PowerSync Custom Actions, you will see errors — these can be safely ignored: - -1. Using `watch()` queries creates a [StreamSubscription](https://api.flutter.dev/flutter/dart-async/StreamSubscription-class.html) and it's important to regularly call `.cancel()` on these to avoid multiple subscriptions for the same query running. -2. Deploying to the Apple App Store currently requires some workarounds due to limitations in FlutterFlow: +3. Using `watch()` queries creates a [StreamSubscription](https://api.flutter.dev/flutter/dart-async/StreamSubscription-class.html) and it's important to regularly call `.cancel()` on these to avoid multiple subscriptions for the same query running. +4. Deploying to the Apple App Store currently requires some workarounds due to limitations in FlutterFlow: 1. Download the code from FlutterFlow 2. Open the `Podfile` located in the `ios/`directory 3. The following option in the `Podfile` needs to be updated from `use_frameworks! :linkage => :static` to `use_frameworks!` (remove everything after the exclamation sign) 4. After removing that option, clean the build folder and build the project again. 5. You should now be able to submit to the App Store -3. Exporting the code from FlutterFlow using the "Download Code" action in FlutterFlow requires the same workaround listed in 4\. above. -4. Other common issues and troubleshooting techniques are documented here: [Troubleshooting](/resources/troubleshooting) +5. Exporting the code from FlutterFlow using the "Download Code" action in FlutterFlow requires the same workaround listed in 4\. above. +6. Other common issues and troubleshooting techniques are documented here: [Troubleshooting](/resources/troubleshooting) diff --git a/integration-guides/supabase-+-powersync.mdx b/integration-guides/supabase-+-powersync.mdx index 5826582d..bd7e493f 100644 --- a/integration-guides/supabase-+-powersync.mdx +++ b/integration-guides/supabase-+-powersync.mdx @@ -4,6 +4,9 @@ description: "Tutorial-style integration guide for creating offline-first apps w sidebarTitle: Overview --- +import CreateCloudInstance from '/snippets/create-cloud-instance.mdx'; +import SupabaseConnection from '/snippets/supabase-database-connection.mdx'; + @@ -106,43 +109,14 @@ create publication powersync for table public.lists, public.todos; **Note:** this guide uses the default `postgres` user in your Supabase account for replicating changes to PowerSync, since elevating custom roles to replication [has been disabled](https://github.com/orgs/supabase/discussions/9314) in Supabase. If you want to use a custom role for this purpose, contact the Supabase support team. -## Configuring PowerSync - -### Connect PowerSync to Your Supabase - -1. In the [PowerSync Dashboard](/usage/tools/powersync-dashboard) Project tree, click on "**Create new instance**": - - - - - -2. Give your instance a name, such as "Supabase Testing". -3. Under the "**General**" tab, you can change the default cloud region from US to EU, JP (Japan), or AU (Australia) if desired (more cloud regions are available, [contact us](/resources/contact-us) if you need a different region). -4. Under the **"DB Connections"** tab, click on the **+** icon. -5. Now we get the connection details from Supabase: - * In your Supabase dashboard, navigate to **"Project Settings"** \-> **"Database" -> "Connection string**" and select the "URI" tab. - * Uncheck the "**Display connection pooler**" checkbox. PowerSync needs to connect to the database directly and cannot use the pooler. - - - -It is important to uncheck this checkbox - * Copy the connection string. The hostname should be `db..supabase.co`, and not, for example, `aws-0-us-west-1.pooler.supabase.com`. - * Paste this URI in PowerSync instance URI field. - * Enter the password for the `postgres` user in your Supabase database: (Supabase also [refers to this password](https://supabase.com/docs/guides/database/managing-passwords) as the _database password_ or _project password_). - * PowerSync has the Supabase CA certificate pre-configured — `verify-full` SSL mode can be used directly, without any custom certificates. -6. Click **"Test Connection"** and fix any errors. -7. Under the **"Client Auth"** tab, enable **"Use Supabase Auth".** - - - -8. Click **"Save".** +## Configuring PowerSync - -The "Supabase Auth" setting no longer works for Supabase projects created after 25 November 2024. While we are working with Supabase on a fix, please apply this workaround: https://releases.powersync.com/announcements/important-notice-for-supabase-users-using-supabase-jwts - +### Create a PowerSync Cloud Instance + -PowerSync deploys and configures an isolated cloud environment for you, which will take a few minutes to complete. +### Connect PowerSync to Your Supabase + ### Configure Sync Rules diff --git a/snippets/create-cloud-instance.mdx b/snippets/create-cloud-instance.mdx new file mode 100644 index 00000000..d98dd36a --- /dev/null +++ b/snippets/create-cloud-instance.mdx @@ -0,0 +1,10 @@ +1. In the [PowerSync Dashboard](/usage/tools/powersync-dashboard) Project tree, click on "**Create new instance**": + + + + + +2. Give your instance a name, such as "Testing". +3. Under the "**General**" tab, you can change the default cloud region from US to EU, JP (Japan), or AU (Australia) if desired. + * Note: More cloud regions are available, [contact us](/resources/contact-us) if you need a different region. +4. Under the **"DB Connections"** tab, click on the **+** icon and select your database technology. \ No newline at end of file diff --git a/snippets/supabase-database-connection.mdx b/snippets/supabase-database-connection.mdx new file mode 100644 index 00000000..586a86ec --- /dev/null +++ b/snippets/supabase-database-connection.mdx @@ -0,0 +1,24 @@ + +1. Copy the database connection details from Supabase: + * In your Supabase dashboard, navigate to **"Project Settings"** \-> **"Database" -> "Connection string**" and select the "URI" tab. + * Uncheck the "**Display connection pooler**" checkbox. PowerSync needs to connect to the database directly and cannot use the pooler. + + + + * Copy the connection string. The hostname should be `db..supabase.co`, and not, for example, `aws-0-us-west-1.pooler.supabase.com`. + * Paste this URI in PowerSync instance **URI** field. + * Enter the **Password** for the `postgres` user in your Supabase database. + * Supabase also [refers to this password](https://supabase.com/docs/guides/database/managing-passwords) as the _database password_ or _project password_. + * PowerSync has the Supabase CA certificate pre-configured — `verify-full` SSL mode can be used directly, without any custom certificates. +2. Click **"Test Connection"** and fix any errors. +3. Under the **"Client Auth"** tab, enable **"Use Supabase Auth"**: + + + +4. Click **"Save".** + + +The "Supabase Auth" setting no longer works for Supabase projects created after 25 November 2024. While we are working with Supabase on a fix, please apply this workaround: https://releases.powersync.com/announcements/important-notice-for-supabase-users-using-supabase-jwts + + +PowerSync deploys and configures an isolated cloud environment for you, which will take a few minutes to complete. \ No newline at end of file