mobile favicon


Get your Supabase user's session from serverside with the serverSupabaseUser service

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

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

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

import { serverSupabaseSession } from '#supabase/server'

export default defineEventHandler(async (event) => {
  return await serverSupabaseSession(event)

Then call your api route from any vue file:

const session = ref(null)

const fetchSession = async () => {
   session.value = await $fetch('/api/session')

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 session = ref(null)

const { data } = await useFetch('/api/session', {
  headers: useRequestHeaders(['cookie'])

session.value = data

Made with Nuxt Studio