Skip to main content

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:

  1. 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 and user:

    Get connections credentials from Supabase

  2. 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:

    Connect Supabase Postgres to Sequin

  3. In the modal, enter the Host and Port for your Supabase database and click Continue.

    Enter host and port

  4. Now, enter the Database name and set the schema name for your sync. For instance, if you're syncing Stripe, you'll likely want to name your synced schema something like stripe. Finally, enter the user and password for your Supabase database and then click Continue. Sequin will verify it can connect to your database.

    Enter additional db details

  5. 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:

    Assign permissions

  6. 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:

Work with Stripe in Supabase

Grant Permissions

To ensure users can access the synced schema Sequin manages, you'll need to run a couple permission grants.

  1. In the Sequin console, click the Connect button next to your sync and copy down your Schema and unique Read Group.

    Get permission details from Sequin

  2. 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.

    TBD

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.