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

    Function createAdminClient

    • Creates an admin Supabase client that bypasses Row-Level Security.

      Uses a secret key for authentication, giving full access to all data. Stateless — one client per request.

      With auth.keyName set, that named key from SUPABASE_SECRET_KEYS is used — and it throws if the key doesn't exist. With keyName omitted, the default key is used, falling back to the first key in the set when no default exists.

      Note this differs from the "secret" auth mode, which matches the default key only and never falls back — see index.AuthModeWithKey.

      Type Parameters

      • Database = unknown

      Parameters

      Returns SupabaseClient<Database>

      index.EnvError If SUPABASE_URL is missing or the specified secret key is not found.

      // Uses the `default` secret key (or the first key if no `default` exists)
      const supabaseAdmin = createAdminClient()
      const { data } = await supabaseAdmin.from('audit_log').insert({ action: 'user_login' })
      const supabaseAdmin = createAdminClient({ auth: { keyName: 'internal' } })