Docs
Supabase Client Libraries

Supabase Client Libraries

Supabase client for Nuxt.js

Installation

Folder structure

  • lib
    • supabase
  • server
    • api
    • middleware
    • supabase
1import { createBrowserClient } from '@supabase/ssr'
2
3export function createClient() {
4  return createBrowserClient(
5    process.env.NUXT_PUBLIC_SUPABASE_URL!,
6    process.env.NUXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY!
7  )
8}

Usage

This block installs a Supabase client for connecting your Nuxt.js project to Supabase. It's designed to fully supports server-side rendering (SSR).

If you've already set up your Supabase client—either using the npm create nuxt@latest template or another method—you can continue using your existing setup.

Getting started

After installing the block, you'll have the following environment variables in your .env.local file:

NUXT_PUBLIC_SUPABASE_URL=
NUXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=
  • If you're using supabase.com, you can find these values in the Connect modal under App Frameworks or in your project's API keys.

  • If you're using a local instance of Supabase, you can find these values by running supabase start or supabase status (if you already have it running).

  • Nuxt recommends NuxtSupabase module to integrate Nuxt application with Supabase. It’s an alternative to this approach, but both approaches are fine.

Further reading