This section assumes you're familiar with Nitro, the server engine powered by Nuxt.

This function is similar to the useSupabaseUser composable but is used in server routes.

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

import { serverSupabaseUser } from '#supabase/server'
export default defineEventHandler(async (event) => {
  return await serverSupabaseUser(event)

Then call your api route from any vue file:

const user = ref(null)
const fetchMe = async () => {
   user.value = await $fetch('/api/me')

Be careful, if you want to call this route on SSR, please read this section, you must send your browser cookies including your supabase token.

const user = ref(null)
const { data } = await useFetch('/api/me', {
  headers: useRequestHeaders(['cookie'])
user.value = data