---
title: "serverSupabaseClient"
description: "Make requests to the Supabase API on server side with the serverSupabaseClient service"
canonical_url: "https://supabase.nuxtjs.org/services/serversupabaseclient"
---
# serverSupabaseClient

> Make requests to the Supabase API on server side with the serverSupabaseClient 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 working similary as the [useSupabaseClient](https://supabase.nuxtjs.org/composables/usesupabaseclient) composable but is designed to be used in [server routes](https://nuxt.com/docs/guide/directory-structure/server#server-routes).

Define your server route and just import the `serverSupabaseClient` from `#supabase/server`. Be careful, `serverSupabaseClient` is returning a promise.

```ts [server/api/libraries.ts]
import { serverSupabaseClient } from '#supabase/server'

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

  const { data } = await client.from('libraries').select('*')

  return { libraries: data }
})
```

Then call your API route from any vue file:

```ts [pages/index.vue]
const fetchLibrary = async () => {
  const { libraries } = await $fetch('/api/libraries')
}
```

Be careful, if you want to call this route on SSR, please read this [section](https://nuxt.com/docs/getting-started/data-fetching#pass-client-headers-to-the-api), you must send your browser cookies including your supabase token.

```ts [pages/index.vue]
const { data: { libraries }} = await useFetch('/api/libraries', {
  headers: useRequestHeaders(['cookie'])
})
```


## Sitemap

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