Nuxt Supabase
Server services

serverSupabaseServiceRole

Make requests with super admin rights to the Supabase API with the serverSupabaseServiceRole service
This section assumes you're familiar with Nitro, the server engine powered by Nuxt.

This function is designed to work only in server routes, there is no vue composable equivalent.

It works similary as the serverSupabaseClient but it provides a client with super admin rights that can bypass your Row Level Security.

The client is initialized with the SUPABASE_SECRET_KEY (recommended) or SUPABASE_SERVICE_KEY (deprecated) you must have in your .env file. We recommend using the new JWT signing keys (SUPABASE_SECRET_KEY) as described in the Supabase blog post.

Define your server route and just import the serverSupabaseServiceRole from #supabase/server.

server/api/bypass-rls.ts
import { serverSupabaseServiceRole } from '#supabase/server'

export default eventHandler(async (event) => {
  const client = serverSupabaseServiceRole(event)

  const { data } = await client.from('rls-protected-table').select()

  return { sensitiveData: data }
})

Then call your API route from any vue file:

pages/index.vue
const fetchSensitiveData = async () => {
  const { sensitiveData } = await useFetch('/api/bypass-rls')
}