Supabase
Sequin syncs platforms like Stripe and Salesforce with Supabase in real-time. With all your data in Supabase, you can build rich applications in no time.
This guide explains how to setup a sync between Sequin and a Supabase Postgres database.
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 modal, 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 you're 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 connect to your database.After Sequin connects to your Supabase Postgres database, it will ask you to confirm which database users should be able to access your synced schema. Select all of the users and click Continue:
Sequin will create a new schema and define a new permissions group to access the schema in your Supabase database. Name the database something like
Supabase
and you're 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:
Grant Permissions
To ensure 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:
GRANT sequin_read_▒▒▒▒ TO postgres, anon, authenticated, service_role;
GRANT USAGE ON SCHEMA {{your_schema_name}} TO anon, authenticated, service_role;
GRANT ALL ON ALL TABLES IN SCHEMA {{your_schema_name}} TO anon, authenticated, service_role;
ALTER 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 Supabase database users can access and read all the tables in your synced schema.
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:
export const supabase_schema = createClient(
'https://xyzcompany.supabase.co',
'public-anon-key',
{
schema: {{your_schema_name}},
}
);
You'll use this client to query for data in your synced schema.
Build!
You can now build on your synced data using all of Supabase's features. Use the Supabase client to query for your data - no HTTP required. Use realtime to trigger changes in your application as soon as data in your synced schema changes. And leverage functions, triggers, and row level security to quickly turn your requirements into features.