Sequin
This guide explains how to quickly setup a sync between Sequin and a Supabase Postgres database.
Sequin allows you to sync platforms like Stripe and Salesforce with Supabase in real-time. You'll be able to read and write to your Stripe customers or Salesforce accounts right from the Supabase client using SQL. Here's how to get setup.
Step 1: Connect Sequin to Supabase#
To connect Supabase to Sequin, you'll first need to retrieve the credentials for your Supabase Postgres database:
-
In the Supabase dashboard, go to the settings page and open up your Database settings. In the Connection info section, you'll find the credentials you need - like
host
anduser
: -
In the Sequin console, go to your sync's configuration and open the Destination section. Select Launch or Connect and then click Connect to configure the connection to your Supabase Postgres:
-
In the connection modal that appears, enter the
Host
andPort
for your Supabase database and click Continue. -
Now, enter the
Database name
and set theschema
name for your sync. For instance, if your syncing Stripe, you'll likely want to name your synced schema something likestripe
. Finally, enter theuser
andpassword
for your Supabase database and then click Continue. Sequin will verify it can properly connect to your database with the correct permissions. -
Sequin is now connected to your Supabase Postgres database and will ask you to confirm which database users should be able to access your synced schema. Select all of the users and click Continue:
-
That's it. Sequin will now create a new schema and permissions group in your Supabase database. Name the database connection in Sequin something like
Supabase
and your done!
In the Supabase dashboard, you can go to the Table Editor and you'll see a new schema full of your synced platform data.
Step 2: Grant Permissions#
To ensure the right users can access the synced schema Sequin manages, you'll need to run a couple permission grants.
-
In the Sequin console, click the Connect button next to your sync and copy down your
Schema
and uniqueRead Group
. -
Now, in the Supabase dashboard, go to the SQL Editor and run the following permission grants:
_10GRANT sequin_read_▒▒▒▒ TO postgres, anon, authenticated, service_role;_10_10GRANT USAGE ON SCHEMA {{your_schema_name}} TO anon, authenticated, service_role;_10_10GRANT ALL ON ALL TABLES IN SCHEMA {{your_schema_name}} TO anon, authenticated, service_role;_10_10ALTER DEFAULT PRIVILEGES FOR ROLE postgres, supabase_admin IN SCHEMA {{your_schema_name}} GRANT ALL ON TABLES TO anon, authenticated, service_role;These permission grants ensure that the various Supabase database users can access and read all the tables in your synced schema.
Step 3: Configure the Supabase Client#
Finally, you'll need to define a new Supabase client in your application to access your synced schema. In the file where you initialized your Supabase client, define a new client with a schema
parameter:
_10export const supabase_schema = createClient(_10 'https://xyzcompany.supabase.co',_10 'public-anon-key',_10 {_10 schema: {{your_schema_name}},_10 }_10);
You'll use this client to query for data in your synced schema.
Resources#
- Sequin official website.
- Sequin Console.
- Sequin documentation.
- Sequin + Supabase + Stripe Tutorial