Changelog

New updates and product improvements

Update

Discussion has been updated with solution chosen.

Realtime Authorization for Broadcast and Presence is now available in Public Beta.

See the official documentation.


Overview

This post explains how authorization works for Realtime Broadcast and Realtime Presence.

This allows you (the developer) to control access to Realtime Channels. We use Postgres Row Level Security to manage access. Developers create Policies which allow or deny access for your users.

Usage

Creating Realtime Policies

Using Studio’s SQL editor you can set RLS rules against the table realtime.messages which will define the rules for your users.


_10
CREATE POLICY "presence sync and broadcast listen to authenticated users"
_10
ON realtime.messages FOR SELECT
_10
TO authenticated
_10
USING ( true );
_10
_10
CREATE POLICY "presence track and broadcast send to authenticated users"
_10
ON realtime.messages FOR INSERT
_10
TO authenticated
_10
WITH CHECK ( true );

Since you are using RLS policies you can do more complex examples.

In a scenario where you have a schema with a table for rooms and one that creates an association between rooms and users.

Example schema to be used in RLS policies

We'll use this example schema to be showcase RLS policies limiting Realtime functionality

We can build more complex RLS rules using this information:


_26
-- Set permission for authenticated users to only listen for Broadcast messages
_26
CREATE POLICY "authenticated can listen to broadcast only on their topics"
_26
ON realtime.messages FOR SELECT
_26
TO authenticated
_26
USING (
_26
exists(
_26
select 1
_26
from public.rooms r join public.rooms_users ru on r.id = ru.room_id
_26
where ru.user_id = auth.uid()
_26
and r.name = realtime.topic()
_26
and realtime.messages.extension = 'broadcast'
_26
)
_26
);
_26
-- Set permission for authenticated users to only write for Broadcast messages
_26
CREATE POLICY "authenticated can write to broadcast only on their topics"
_26
ON realtime.messages FOR INSERT
_26
TO authenticated
_26
WITH CHECK (
_26
exists(
_26
select 1
_26
from public.rooms r join public.rooms_users ru on r.id = ru.room_id
_26
where ru.user_id = auth.uid()
_26
and r.name = realtime.topic()
_26
and realtime.messages.extension = 'broadcast'
_26
)
_26
)

Testing Authorization

Now to test it we can use a quick deno script by creating a index.ts


_21
// Run with deno run --allow-net --allow-env --allow-read --allow-ffi index.ts
_21
import { createClient } from "npm:@supabase/supabase-js@2.38.5";
_21
const url = "https://<project_ref>.supabase.com";
_21
const apikey = "<api_key>";
_21
_21
const client = createClient(url, apikey);
_21
_21
const channel = client.channel("channel_1", {
_21
config: { broadcast: { self: true }, private: true},
_21
});
_21
channel
_21
.on("broadcast", { event: "test" }, (payload) => console.log(payload))
_21
.on("presence", { event: "join" }, (payload) => console.log(payload))
_21
.on("presence", { event: "leave" }, (payload) => console.log(payload))
_21
.subscribe((status: string, err: any) => {
_21
if (status === "SUBSCRIBED") {
_21
console.log("Connected!");
_21
} else {
_21
console.error(err);
_21
}
_21
});

This will return an error with the message You do not have permissions to read from this Topic

But if we change our code to pass along an authenticated user, then we will be able to connect and receive / send messages.


_28
import { createClient } from "npm:@supabase/supabase-js@2.38.5";
_28
const url = "https://<project_ref>.supabase.co";
_28
const apikey = "<api_key>";
_28
_28
const client = createClient(url, apikey);
_28
_28
await client.auth.signInWithPassword({
_28
email: "<email>",
_28
password: "<password>",
_28
});
_28
_28
client.realtime.setAuth(
_28
(await client.auth.getSession()).data.session.access_token
_28
);
_28
const channel = client.channel("channel_1", {
_28
config: { broadcast: { self: true }, private: true },
_28
});
_28
channel
_28
.on("broadcast", { event: "test" }, (payload) => console.log(payload))
_28
.on("presence", { event: "join" }, (payload) => console.log(payload))
_28
.on("presence", { event: "leave" }, (payload) => console.log(payload))
_28
.subscribe((status: string, err: any) => {
_28
if (status === "SUBSCRIBED") {
_28
console.log("Connected!");
_28
} else {
_28
console.error(err);
_28
}
_28
});

Do not forget that RLS policies can use other tables in them so this will give you all the flexibility you need to better fit your use case but be aware of the performance impact of heavy RLS queries or non-indexed fields.

Migrating from Public Channels

On connect, you need to send in the configuration that the channel will be private: true

Client library

We’re working on the next version actively so we can provide a good developer experience.

Please check the latest next version at https://www.npmjs.com/package/@supabase/realtime-js?activeTab=versions

This library as changed the configuration settings to add private: true on channel connect to determine if the user will be connecting an RLS checked channel.

How it works

Connection context

When you connect with Realtime we set a connection configuration with your JWT, Topic and Headers using the following query:


_10
SELECT
_10
set_config('role', $1, true),
_10
set_config('realtime.topic', $2, true),
_10
set_config('request.jwt', $4, true),
_10
set_config('request.jwt.claims', $6, true),
_10
set_config('request.headers', $7, true)

This query is only run when you connect to a topic.

We’re also providing a new function to easily fetch the realtime.topic configuration with


_10
SELECT realtime.topic();
_10
_10
-- Usage example
_10
CREATE POLICY "authenticated users can only write to topic named foo"
_10
ON realtime.messages FOR INSERT
_10
TO authenticated
_10
WITH CHECK ( realtime.topic() = 'foo' );

Applying RLS Policies

To achieve RLS checks on your Realtime connection we created a new table in the realtime schema to which you will be able to write RLS rules against it to control your topics extensions.

You won’t see any entries recorded in this table as we rollback the changes made to test out RLS policies to avoid creating clutter in your database.

Supavisor, Supabase's multi-tenant connection pooler deployed to regional clusters, became production ready back in December 2023. You can read the announcement here.

Since then, we've migrated Supabase projects from PgBouncer, single tenant connection pooler deployed to the project's instance, to Supavisor.

However, we kept the previous client connection limits from PgBouncer during the transition across all compute instances.

Today, we're happy to announce that we've increased this limit for compute instances Small, Medium, Large, and XL so your projects can take advantage of additional client connections while pricing remains unchanged. These new limits have already been applied to all existing projects and any new projects spun up.

Here's a quick breakdown:

Compute SizePrevious Client LimitsNew Client Limits
Small200400
Medium200600
Large300800
XL7001,000

For a more complete breakdown of your compute instance resources head over to the Compute Add-ons page.

Update to the UI for RLS policies

image

We've been looking into improving the UX for the RLS policy UI after going through feedback of the community's struggles with RLS in general, and this is the next step that we're taking to streamline the UX.

What we're calling as a "hybrid" editor (for now), you'll be able to see the corresponding SQL query for creating or updating your RLS policies while you're editing the policy via the input fields. And if you'd like even greater control, there's always the "Open in SQL Editor" button as an escape hatch where you can edit the SQL query in its entirety.

Templates are now right beside the editor as well, so you no longer have to click back and forth between templates and the editor.

We've always seen the dashboard as more than just a database adminstration tool, but also potentially an educational platform for developers to pick up the SQL language as they build out their database, and we hope that the changes here will help make that even easier.

PR: https://github.com/supabase/supabase/pull/21806

Link: https://supabase.com/dashboard/project/_/auth/policies

Connection pooler on port 6543 is set to transaction mode permanently

Previously, connection pooler's port 6543 can be set to either transaction or session mode under your project's database settings. This change makes it easier to distinguish between pooler modes and ports by only enabling transaction mode on port 6543 while maintaining session mode on port 5432.

If your using port 6543 and your project's pooler mode is transaction then you won't be able to set the mode to session. You can use port 5432 for session mode.

If your using port 6543 and your project's pooler mode is session then we strongly advise that you use port 5432 for session mode and change the mode to transaction. Once this setting is saved you won't be able to set session mode on port 6543.

PR: https://github.com/supabase/supabase/pull/22150

Link: https://supabase.com/dashboard/project/_/settings/database#connection-pooler

Other improvements and bug fixes

[General]

  • Home page connect modal fix broken link under pooler mode to Database Settings [PR]
  • Fix toast messages to handle really long messages, and support closing them in such scenarios [PR]

[Auth]

  • Fix applying table privileges to incorrect table if there any more than 1 table with the same name in different schemas [PR]

[Table Editor]

  • Prevent updating RLS via GUI for tables under protected schemas [PR]
  • Support updating column "is unique" when editing table in side panel [PR]
  • Fix support NULL values when importing data via CSV text [PR]
  • Ensure that table and column names are trimmed for whitespaces when saving [PR]

[Storage Explorer]

  • Fix delete bucket modal styling when bucket name is long [PR]
  • Fix deleting parent folder not deleting child folders despite child folders being empty [PR]

[Database Pages]

  • Fix inability to manage foreign keys [PR]
  • Validate enumerated types to ensure names do not conflict with native PG data type names [PR]
  • Validate enumerated types to ensure names do not conflict with native PG data type names [PR]
  • Fix Stripe foreign data wrapper to support selecting a rowid_column, addresses the issue of not being able to update stripe foreign tables [PR]

In our previous platform architecture, our Storage, Realtime, and connection pooler (PgBouncer) services were bundled together, with a single instance of each service per project.

For our v2 architecture, we’ve “unbundled” these services, moving to a multi-tenant model, where a single instance of each service serves many projects:

This frees up as much resources as possible for your Postgres databases, while enabling us to offer more resource intensive features for these services, and opens the door to capabilities such as zero-downtime scaling.

With Supavisor replacing PgBouncer, along with some other key optimizations, the final pieces of our v2 architecture are now ready.

We’ve already fully rolled out our v2 architecture to paid plan projects. You now have more resources available, for the same price that you’ve been paying.

Free plan gradual rollout (20 March 2024 onwards)

  • 20 March 2024: Newly created or unpaused projects will use v2 architecture
  • 28 March 2024: Existing projects will start being migrated to v2 architecture

This will be a gradual rollout - we will email you at least one week before your project is scheduled to be migrated.

Your action for projects scheduled to be migrated

For newly created or unpaused projects on the Free Plan, no action is required.

For existing projects on the Free Plan, up to a few minutes of downtime is expected for the migration. For each of your projects, we’ll identify the 30-minute maintenance window where your project had the least database queries over the previous 10 weeks.

You have two choices:

  • Automatic Migration: If you don't take any action, we plan to do the migration automatically during that maintenance window with the least historical activity.
  • Manual Migration: Any time before that, you can go to Project Settings > General to see whether/when the maintenance window is scheduled (timings will also be included in the email). There, you may choose to manually restart the project yourself, at a time that is convenient for you. Your project will be restarted on v2 architecture.

Conversational AI assistant now available as part of the SQL Editor

As part of our ongoing efforts to introduce the AI assistant across the dashboard, we're bringing the AI assistant to the SQL Editor next! Some of you might have already been using the AI assistant in the SQL Editor through the green bar at the top of the editor - we're sprucing it up by extending it further to a conversational UX. Go back and forth with the assistant and apply the code snippets that you deem to be the most appropriate!

This is currently under a feature preview - you may enable this feature by clicking on the user icon while in a project at the bottom of the side navigation bar and selecting "Feature previews". From there just enable the preview under "SQL Editor Conversational Assistant". And as always, we're incredibly open to any feedback for this, so give us a shout right here!

PR: https://github.com/supabase/supabase/pull/21388

Link: https://supabase.com/dashboard/project/_/sql/new

Other improvements and bug fixes

Table Editor

  • Fix creating a table will automatically trim for whitespaces (PR)

SQL Editor

  • Fix snippet names not truncating (PR)

Auth Policies

  • Fix error message not surfacing in new RLS UI from feature preview (PR)

Database Functions

  • Fix light mode styling for code editor (PR)

Matryoshka Embeddings: Faster OpenAI Vector Search Using Adaptive Retrieval

Learn about how OpenAI’s newest text embeddings models, text-embedding-3-small and text-embedding-3-large, are able to truncate their dimensions with only a slight loss in accuracy.

Blog post

Easily Connect to Supabase Projects From Frameworks and ORMs of Your Choice

Connect to Supabase from any framework or ORM with our new “Connect” panel in Studio. This displays simple setup snippets that you can copy and paste into your application. We’ve started with a selection of popular frameworks and ORMs and you can request more by feature request or pull request.

Pull request

PostgREST Aggregate Functions

PostgREST v12 has been released, and with it, comes the release of the highly requested aggregate functions, avg(), count(), sum(), min(), and max(), that is used to summarize data by performing calculations across groups of rows.

Blog post

Terraform Provider to Manage Resources on Supabase Platform

We’ve created an official Supabase Provider for Terraform to version-control your project settings in Git. You can use this provider in CI/CD pipelines to automatically provision projects and branches and keep configuration in code.

Learn more

Support for Composite Foreign Keys in Table Editor

We've shifted the management of foreign keys into the Table Editor’s side panel so you can easily see all foreign keys pertaining to a table as well as referencing columns to composite foreign keys.

Pull request

Build a Content Recommendation App With Flutter and OpenAI

Learn about how we built a movie listing app that recommends another movie based on the movie that a user is currently viewing built with Supabase, Flutter, and OpenAI.

Blog post

Load Testing Supabase

Performance testing evaluates a system's compliance with its performance requirements. It reveals your app’s ability to handle user load, unexpected spikes, or recover from stressful workloads. In this blog post you will learn about how we automated our performance testing.

Blog post

More Studio Updates

  • Collapsible main sidebar navigation [PR]
  • Create charts from SQL Editor [PR]
  • Resizable main tabs in Table Editor and SQL Editor [PR]
  • View user metadata from the dashboard [PR]
  • Bulk delete SQL Editor snippets [PR]
  • Query Performance updates [PR]
  • Choose a compute option when creating a project (Paid organizations only) [PR]
  • Logs Explorer facelift [PR]

Quick Product Announcements

  • [Auth] Require AAL2 to enroll additional factors for MFA enrollment [PR]
  • [Storage] Increased maximum file upload size to 50GB for paid plans [PR]

Made With Supabase

  • Inkvestigations is a webgame using LLM technology (currently GPT) to create interactive mystery games [GitHub]
  • MathPuzzles- a multiplayer game to outsmart your friends [GitHub]
  • Create a recipe app with Nowa [Article]
  • Open-source AI wearable device that captures what you say and hear [GitHub]
  • Brick yourself - turn yourself into a mini-figure [Website]

Community Highlights

  • SupaVlog: Vlog Application Starter Kit Built with Supabase, Stream, Hookdeck, and Next.js [Article]
  • Chat with Supabase PostgreSQL using AI [Article]
  • How to implement Google sign-in on Flutter with Supabase on iOS, Android and the Web [Video]
  • They're Making Supabase Better... [Video]
  • How to send welcome emails with Supabase edge functions and database triggers [Article]
  • How to Create Email Signup and Login Screens in React Native (Expo), ExpressJS, and Supabase [Article]
  • Integrating Supabase with Flutterflow [Video]
  • Join the #SupaBuilders movement and never get your project paused again!

This discussion was created from the release Platform Updates: February 2024.

Templates added to new RLS assistant

If you're not aware yet, we previously created a new RLS UI that comes integrated with the Supabase Assistant to (hopefully) help everyone write RLS policies easier and faster. This is currently still a feature preview which you can enable by clicking on your user profile at the bottom of the side navigation bar. We're continuously trying to see how we can improve this to make it a much better UX than the current existing RLS policy user flow.

The first gap that we're trying to address is the ease of referencing existing templates that just work out of the box from the current RLS policy flow - those proved to be really useful when trying to understand the syntax of writing policies, and so we added that in to the new RLS UI. Not just that but we also added more complex templates that work better in the new UI than the current one!

The next item that we're looking into is to see what minimal guard rails we can add to make writing RLS policies even less intimidating since the new UI expects only SQL input. One of the aims of the dashboard is to guide our users to not be afraid of SQL no matter the level of proficiency and we hope that we'll be able to cook up the ideal UX that will allow everyone to write SQL with confidence.

PR: https://github.com/supabase/supabase/pull/21447

Link: https://supabase.com/dashboard/project/_/auth/policies

Collapsible navigation bar

https://github.com/supabase/supabase/assets/8291514/070cb030-d249-404d-82cd-3ba92d9309f3

We received many feedback that the icons alone in the navigation bar are not too intuitive in understanding what page they're navigating too. So finally, we're adding some textual cues that show up on hover to the navigation bar in hopes to make navigating around the dashboard easier!

PR: https://github.com/supabase/supabase/pull/21550

Link: https://supabase.com/dashboard/project/_

Make charts in the SQL editor

For the users who leverage on SQL to analyze data, this should be useful for you! You can now plot your data points through the SQL editor after running your query. Choose which columns to be your axes and you're good to go. As always - feel free to drop any feedback for us on this! We're keen to see how else we can make this feature better and stronger 😄

PR: https://github.com/supabase/supabase/pull/21638

Link: https://supabase.com/dashboard/project/_/sql/new

Foreign Key Management re-introduced into the Column side panel editor

We previously made an update in the Table Editor to shift the management of foreign keys to the table editor as an effort to properly support composite foreign keys. This understandably caused the UX to suffer as we received many feedback around creating simple 1:1 foreign key relations much more troublesome. We've thus re-introduced being able to manage your foreign keys while editing a column! Thank you so much for everyone's feedback around this - it's something that we genuinely appreciate our community for! 🙏

PR: https://github.com/supabase/supabase/pull/21683

Link: https://supabase.com/dashboard/project/_/editor

Toggle intellisense for the SQL editor

Intellisense for the SQL editor was always enabled by default for everyone, but we're now making this a toggleable feature - this is more specifically useful for large projects with many tables as we've noticed the amount of data we try to load into intellisense causes the SQL editor to slow down noticeable (likely due to browser memory issues).

PR: https://github.com/supabase/supabase/pull/21643

Link: https://supabase.com/dashboard/project/_/sql/new

Other improvements and bug fixes

Schema Visualizer

  • Added legends to the schema visualizer and align icons properly [PR]

Paid plan users can now immediately launch projects on larger compute sizes. Previously, paid organizations had to launch projects on the default "Micro" instance and then separately upgrade their instance. You can always up and downgrade your instance in hindsight. Feel free to leave any feedback in our discussions here!

PR: https://github.com/supabase/supabase/pull/21292

Link: https://supabase.com/dashboard/new/_

Update on Table Editor search input

Screenshot 2024-02-23 at 7 59 21 PM

As mentioned in last week's changelog (and also as always 😉) we see everyone's feedback regarding the changes to the table editor search input and have enacted a slight change to make the search action more prominent and easier to click on! Again, thank you to everyone for sounding your thoughts, we genuinely appreciate them as it helps us guide the dashboard's DX to be optimal - keep em coming!

Separetely - we're also aware of the feedback regarding our change in the way you manage your foreign keys as announced in the changelog discussion 2 weeks ago - fret not! We're actively looking into that as well 🙂

PR: https://github.com/supabase/supabase/pull/21486

Link: https://supabase.com/dashboard/project/_/editor

Resizeable inner sidebars for Table Editor and SQL Editor

https://github.com/supabase/supabase/assets/8291514/1f3d04ef-df86-4398-b7b3-42a9effe950d

For those who might have tables or SQL queries with long names, this should help alleviate some issues with the names truncating. Hopefully it'll be easier to find your tables / SQL queries! 😊

PR: https://github.com/supabase/supabase/pull/21548

Link: https://supabase.com/dashboard/project/_/editor

Connecting to your project - added Expo React Native guides

Last week we announced a quicker way to get your project's connection parameters on the project's home page and we're heartened to already see some community contributions to add more content for different frameworks! Shoutout to @Hallidayo for the help on this - we're always keeping an eye out for more of such contributions 😄

PR: https://github.com/supabase/supabase/pull/21350

Link: https://supabase.com/dashboard/project/_

Other improvements and bug fixes

Home

  • Sort projects alphabetically and add search functionality for projects (PR)

Table Editor

  • Fix missing role impersonation functionality when opening a view (PR)
  • Fix a11y on table menu items (PR)
  • Fix inability to update primary key of a table after renaming the table (PR)

SQL Editor

  • Fix error highlighting wrong line if running a selected portion of the query (PR)

Paid plan users can now immediately launch projects on larger compute sizes. Previously, paid organizations had to launch projects on the default "Micro" instance and then separately upgrade their instance. You can always up- and downgrade your instance in hindsight.

A quicker way to get your project's connection parameters

We've made retrieving your project's connection parameters more easily accessible by adding a "Connect" button to each projects' homepage. This will show you some quick instructions on how to either connect to your database directly, or connect to your project via some app frameworks and ORMs. Hopefully this will help both new and familiar developers on Supabase to get to building quicker without having to jump around the dashboard to find these information.

PR: https://github.com/supabase/supabase/pull/20328

Link: https://supabase.com/dashboard/project/_

Table Editor side menu revamp

screenshot-2023-12-22-at-13 06 32

We're in the midst of revising the UX around the table editor to ensure that controls aren't sprawled across the page despite us building more and more features - and this is just the first step of more to come. Icons for tables and views have been tweaked to be more minimal, each table has an indicator to whether RLS has been enabled or not, and the search bar has been made a tad sleeker. As an assurance, we definitely hear everyone's feedback about the changes here in particular with the search bar being less visible and are actively looking to improve the experience here! 🙏

PR: https://github.com/supabase/supabase/pull/19977

Link: https://supabase.com/dashboard/project/_/editor

Table Editor header simplification

Similar to the above, we've updated the layout a little for the Table Editor itself, briefly the changes include

  • Support for enabling RLS from the Table Editor
  • Showing an indication of how many policies the table has
  • Shifting refresh + data/definition toggle to the footer of the grid

All these are tiny steps to allowing us to build more functionality into the Table Editor without turning it into a control panel!

PR: https://github.com/supabase/supabase/pull/18366

Link: https://supabase.com/dashboard/project/_/editor

View auth user details

We've had some feedback from users that they'd want a convenient way to check on their project's users from the UI rather than having to go through the Table Editor or SQL Editor to query the auth.users table, and so we've gone ahead to ship this one.

PR: https://github.com/supabase/supabase/pull/21239

Link: https://supabase.com/dashboard/project/_/auth/users

Other improvements and bug fixes

Table Editor

  • Fix definition view showing empty result if formatting the definition throws an error (PR)

SQL Editor

  • Refocus to code editor after closing destructive query warning modal (PR)

Authentication

  • Fix policies under tables from "protected" schemas not showing RLS disabled/enabled state (PR)
    • Also show "protected" schemas notice when viewing policies of tables under those schemas
  • Clicking "Toggle feature preview" from the new RLS creation UI will show a confirmation dialog if changes were made before closing the panel (PR)

Storage

  • Renaming a file will just highlight the name of the file without the extension, similar to MacOS (PR)

Build in a weekend, scale to millions