Supabase

Reylo on Supabase's Postgres

A Supabase project is a Postgres database, so everything on the Postgres page holds for it.

DialectPostgres
The type check readsThe direct connection or the session pooler, and in development the database supabase start runs
Driverspostgres.js or pg, through any of Supabase's connections
MigrationsThe Supabase CLI's, in supabase/migrations, applied to the local database, or reylo migrate through the session pooler or the direct connection, never port 6543
JavaScript clientCalls Supabase's REST API, so .run() doesn't take it (Drivers)

Connection

The type check reads the direct connection or the session pooler, never the transaction pooler:

.env
# the transaction pooler, for your app
DATABASE_URL=postgresql://postgres.<ref>:…@<pooler host>:6543/postgres
# the session pooler, for the type check
DIRECT_URL=postgresql://postgres.<ref>:…@<pooler host>:5432/postgres

Then point Reylo at the direct connection:

.reylo.yaml
# the direct connection or the session pooler, never the shared pooler's port 6543
direct_url: ${DIRECT_URL:-${DATABASE_URL}}

Why not the transaction pooler:

  • The type check prepares each query on its session. The transaction pooler shares sessions between clients, so their prepared queries collide. The type check refuses its port, 6543.
  • Copy each connection string from the Connect panel of your project's dashboard.
  • The direct connection is IPv6 only, unless your project has Supabase's IPv4 add-on. From a network without IPv6, use the session pooler.
  • With no TLS setting in the URL, Reylo tries TLS by default (sslmode=prefer); add sslmode=require to require encryption. To verify Supabase's certificate too, download it from your project's database settings and pass it in the URL.

Drivers

Run queries with postgres.js or pg. Through the transaction pooler, create a postgres.js client with prepare: false:

import  from "postgres";
import  from "./get_note.sql";

// the transaction pooler, on port 6543
const  = (.., { : false });
const  = await .(, { :  });
import  from "pg";
import  from "./get_note.sql";

// any of supabase's connections, with no setting
const  = new .({ : .. });
const  = await .(, { :  });
select id, body, created_at from  where id = :id::uuid

Through the transaction pooler:

  • Reylo prepares its queries on postgres.js as postgres.js prepares its own, so with prepare: false they run unprepared too.
  • Reylo's queries on pg are unnamed statements, which the transaction pooler runs with no setting.
  • Supabase's Postgres.js guide notes that postgres.js pipelines queries, which the transaction pooler can answer out of order.
  • The @supabase/supabase-js client calls Supabase's REST API, which takes no SQL, so .run() can't use it. Create a postgres.js or pg client for your Reylo queries.

Local development

Point the type check at the database supabase start runs:

.env
# supabase start's database
DATABASE_URL=postgresql://postgres:postgres@127.0.0.1:54322/postgres

Write each migration in supabase/migrations, and apply it to that database with the Supabase CLI:

# a new file in supabase/migrations
supabase migration new add_notes
# the migrations not applied yet
supabase migration up
# or the whole database again, from every migration and supabase/seed.sql
supabase db reset

To use Reylo Migrate instead, start it from that database. Its migrations run on each new Supabase database:

reylo migrate init
# on a new database: the local one after supabase db reset, a branch, a project
reylo migrate deploy

A project begun with Reylo v0.8 or earlier creates supabase_realtime in its init.sql, which every Supabase database has already. Start its migrations again from your development database, then record them on each other database:

mv reylo reylo-old
reylo migrate init
reylo migrate history push --url <url>

The new init.sql makes the schema alone. Insert the rows a new database needs in a new migration, skipping rows already there:

insert into plans (id, name) values (1, 'free') on conflict do nothing;

About the local database:

  • The local database has Supabase's own schemas, such as auth and storage. A query that reads auth.users is typed as it is on your project.
  • The type check reads every .sql file included by tsconfig.json, and multi-statement migrations fail as queries. If include matches supabase/ (such as **/*), add "exclude": ["supabase"].

CI

Start the same database in CI with the Supabase CLI, which applies your migrations:

.github/workflows/ci.yml
jobs:
  check:
    runs-on: ubuntu-latest
    env:
      DATABASE_URL: postgresql://postgres:postgres@127.0.0.1:54322/postgres
    steps:
      - uses: actions/checkout@v7
      - uses: supabase/setup-cli@v1
      # postgres alone, with your migrations and seed applied
      - run: supabase db start
      - uses: actions/setup-node@v7
        with: { node-version: 24 }
      - run: npm ci
      - run: npm run typecheck
      - run: npm run build

Floats

Supabase's Postgres prints floats rounded, so 0.1::float8 + 0.2 comes back 0.3. To read exact values, set extra_float_digits on the role you connect as:

alter role postgres set extra_float_digits = 1;

Once that runs:

  • Connections that start after it read exact values.
  • The local database rounds floats the same way. Put the statement in a migration, so that it reaches your project, the local database and CI.

Row Level Security

Reylo runs each query as the role your client connects as. Supabase's connection strings connect as postgres, which bypasses Row Level Security, so no policy filters those queries.

To run a query as a signed-in user, switch to the authenticated role in a transaction, with the user's claims:

import  from "postgres";
import  from "./list_notes.sql";

const  = (.., { : false });

const  = await .(async () => {
  await `set local role authenticated`;
  // auth.uid() reads the claims' sub
  const  = .({ : , : "authenticated" });
  await `select set_config('request.jwt.claims', ${}, true)`;
  return .();
});
select id, body from  order by created_at desc

A policy for authenticated then filters the rows:

alter table  enable row level security;
create policy "own " on  for select to authenticated
  using (user_id = auth.uid());
Released under the MIT License. Copyright © 2026 Colin McDonnell.

On this page

reylosql/reylo