@supabase/server - v1.7.0
    Preparing search index...

    Function withSupabaseAdminClient

    • Alpha

      Alpha. Contributes ctx.supabaseAdmin — an admin Supabase client that bypasses Row-Level Security, authenticated with a secret key. This is the same middleware withSupabase composes internally to build its context.

      The client is constructed on the first property access of ctx.supabaseAdmin and memoized for the request. A handler that never accesses it requires no secret key.

      Type Parameters

      • Database = any

      Parameters

      Returns Entry<{ supabaseAdmin: SupabaseClient<Database> }>

      index.EnvError When SUPABASE_URL or the secret key is missing — thrown at the first ctx.supabaseAdmin property access, inside the handler or downstream middleware that performs it.

      import { pipeline } from '@supabase/middleware'
      import { withSupabaseAdminClient } from '@supabase/server/middleware/admin-client'

      export default {
      fetch: pipeline([withSupabaseAdminClient()], async (req, ctx) => {
      await ctx.supabaseAdmin.from('audit_log').insert({ action: 'ping' })
      return Response.json({ ok: true })
      }),
      }

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