RedwoodJS with Realtime Subscription

Hi Redwood, meet, Supabase adds realtime and RESTful APIs to your existing PostgreSQL database without a single line of code. has superpowers and could easily replace Prisma2 :mask:


  • Many systems that give you realtime functionality require you to update via the same interface that the listener is on. Supabase is source agnostic. Update your database from anywhere and you’ll still get the changes.

  • Scale the realtime servers without putting any additional load on your DB. All you need is one connection to your database, and you can handle thousands (or millions) or users

  • Listening to data changes on client side solves stale data problems and update collisions.

In implementing subscription for RedwoodJS, which could be a win for RedwoodJS instead of waiting for Prisma2 to implement subscription, I think we should take a look at how achieved real-time/reactivity with Postgres using its real-time feature with examples showing how it works with NextJS. Supabase is a service that introspect your database to give you instant, custom documentation for your REST and Realtime APIs. Supabase Realtime, built with Elixir, listens to your to PostgreSQL database in realtime via websocket. My team already worked with Supabase Realtime in the past and were able to get subscription working with NextJS using the open source Realtime Docker image provided by Supabase to listen to Postgres NOTIFY.

At its core, Supabase is an Elixir server that allows you to listen to PostgreSQL inserts, updates, and deletes using websockets. Supabase listens to Postgres’ built-in replication functionality, converts the replication byte stream into JSON, then broadcasts the JSON over websockets.

Listen to your Prisma Postgres tables by following instructions here

1 Like

Ok, woah, this is really interesting.

(Couple quick notes: this wouldn’t be something to replace Prisma 'cause there’s much more to Prisma than querying postgres. Also, the Subscriptions hold-up is with Netlify Functions not supporting the AWS API Gateway for websockets, pubsub, etc. See my comment in this thread.)

What if you ran Supabase alongside the existing Redwood architecture for Subscriptions support? :star_struck:

I’m thinking off the top of my head, but take a look at how Prisma (and specifically Prisma Client) is being implemented in the API across services, SDL, and the function graphql.js. db is the PrismaClient() from lib/db.js. It’s possible to add other DB connections, you’ll just need to handle the API setup accordingly.

And if the API is deployed to Netlify Functions, will Supabase Subscriptions be compatible? Or would that require a different deploy target?

1 Like