Tutorials

How to send Supabase Change-data-capture events to Memphis.dev

Yaniv Ben Hemo January 15, 2023 2 min read

Introduction

Supabase is an open-source Firebase alternative.

In databases, change-data-capture (or CDC) is a set of software design patterns used to determine and track the data that has changed so that action can be taken using the changed data or because of it.

In simple words: Each time a new event occurs on a specific table, such as INSERT / UPDATE / DELETE, an event will be created and, if configured – published to a destination so some service will be notified for it.

Flow

  1. Sign up to Memphis.dev Cloud or Deploy Memphis OS
  2. Create a new Supabase table.
  3. Configure a webhook for the newly created table.
  4. Check the incoming CDC events in Memphis.

Supabase CDC webhook with Memphis


Step 1: Prepare your Memphis.dev Account

In this tutorial, we will focus on using Memphis.dev Cloud, but the following steps should be similar when using Memphis.dev OS as well.

Once an account has been created, please head to the users section and create a new client-type application:

Now, generate a JWT token to be used for the REST requests between Supabase and Memphis.dev. Make sure to keep the generated token. It will be needed in step 3.


Step 2: Create a new Supabase table

Supabase CDC webhook with Memphis

Supabase CDC webhook with Memphis


Step 3: Configure a webhook for the newly created table

Head to Database -> Webhooks -> Create a webhook

Supabase CDC webhook with Memphis

A change-data-capture event can occur and be sent for every “INSERT”, “UPDATE”, and/or “DELETE” command that takes place in the configured table.

Configure the webhook based on your use case requirements –

Supabase CDC webhook with Memphis

Supabase CDC webhook with Memphis

  • Method: POST
  • URL: https://aws-eu-central-1.restgw.cloud.memphis.dev/stations/supabase/produce/single
  • Headers:
    • Content-type: application/json
    • Authorization: Bearer <JWT Token>

Supabase CDC webhook with Memphis


Step 4: Check for incoming CDC events

Insert a new record into the created Supabase table. Because we selected the INSERT type of events, it should output an event.

Supabase CDC webhook with Memphis

Return to the Memphis dashboard and into the “supabase” station and check the center panel –
events can be seen in the center panel, and the parsed payload on the right-bottom.