---
title: "serverSupabaseSession"
description: "Get your Supabase user's session from serverside with the serverSupabaseUser service"
canonical_url: "https://supabase.nuxtjs.org/services/serversupabasesession"
---
# serverSupabaseSession

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

<warning>

This section assumes you're familiar with [Nitro](https://v3.nuxtjs.org/guide/concepts/server-engine), the server engine powered by Nuxt.

</warning>

This function is similar to the [useSupabaseSession](https://supabase.nuxtjs.org/composables/usesupabasesession) composable but is used in [server routes](https://nuxt.com/docs/guide/directory-structure/server#server-routes).

<warning>

Be advised that `serverSupabaseSession` is considered unsafe, since the session comes from the client and users can tamper with it. For checking if the user is logged in, always use [serverSupabaseUser](https://supabase.nuxtjs.org/services/serversupabaseuser)

</warning>

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

```ts [server/api/session.ts]
import { serverSupabaseSession } from '#supabase/server'

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

Then call your api route from any vue file:

```ts [pages/index.vue]
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](https://nuxt.com/docs/getting-started/data-fetching#isomorphic-fetch-and-fetch), you must send your browser cookies including your supabase token.

```ts [pages/index.vue]
const session = ref(null)

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

session.value = data
```


## Sitemap

See the full [sitemap](https://supabase.nuxtjs.org/sitemap.md) for all pages.
