Server: withPostgresAdminClient

Alpha. Contributes ctx.postgresAdmin — a pg client that bypasses RLS, for full-table access. The direct-connection counterpart to withSupabaseAdminClient, and the deliberate opt-out from the guardrails withPostgresClient (@supabase/server/middleware/postgres) enforces.

Queries run as-is, as the role in the connection string: no claim injection, no role switching, no wrapping transaction. Whatever that role may read, the caller may read.

Unlike withPostgresClient this declares no upstream prerequisite — it never looks at ctx.jwtClaims, so it composes in any auth mode, including auth: 'secret' and auth: 'none':

import { pipeline } from '@supabase/middleware'
import { withSupabase } from '@supabase/server'
import { withPostgresAdminClient } from '@supabase/server/middleware/postgres-admin'

pipeline([withSupabase({ auth: 'secret' }), withPostgresAdminClient()], handler)

Compose both halves when a handler needs each in turn — they share one pool, and ctx.postgres stays RLS-scoped regardless:

pipeline([withSupabase({ auth: 'user' }), withPostgresClient(), withPostgresAdminClient()], handler)

Authorization is yours now. RLS is not consulted, so any per-user scoping has to be a where clause you write. Reach for withPostgresClient unless you specifically need to cross user boundaries.

Runtime note. pg needs raw TCP, so this runs on Node/Deno (including the Supabase Edge runtime), not on Workers-style isolates.

The composable middleware surface tracks @supabase/middleware 0.x — entry shapes, context keys, and config options may change between 0.x releases.