Skip to main content
Version: v2 RC


You can initialize a new Supabase client using the createClient() method.

The Supabase client is your entrypoint to the rest of the Supabase functionality and is the easiest way to interact with everything we offer within the Supabase ecosystem.


  • supabaseUrlrequiredstring

    The unique Supabase URL which is supplied when you create a new project in your project dashboard.

  • supabaseKeyrequiredstring

    The unique Supabase Key which is supplied when you create a new project in your project dashboard.

  • SupabaseClientOptionsrequiredobject

    No description provided.

    • authoptionalobject

      No description provided.

      • autoRefreshTokenoptionalboolean

        Automatically refreshes the token for logged in users.

      • cookieOptionsoptionalobject

        Options passed to the gotrue-js instance

      • detectSessionInUrloptionalboolean

        Detect a session from the URL. Used for OAuth login callbacks.

      • persistSessionoptionalboolean

        Whether to persist a logged in session to storage.

      • storageoptionalobject

        A storage provider. Used to store the logged in session.

      • storageKeyoptionalstring

        Optional key name used for storing tokens in local storage

    • dboptionalobject

      The Postgres schema which your tables belong to. Must be on the list of exposed schemas in Supabase. Defaults to 'public'.

      • schemaoptionalSchemaName

        No description provided.

    • globaloptionalobject

      No description provided.

      • fetchoptionalFetch

        A custom fetch implementation.

      • headersoptionalRecord

        Optional headers for initializing the client.

    • realtimeoptionalRealtimeClientOptions

      Options passed to the realtime-js instance



import { createClient } from '@supabase/supabase-js'

// Create a single supabase client for interacting with your database
const supabase = createClient('', 'public-anon-key')

With additional parameters

import { createClient } from '@supabase/supabase-js'

const options = {
db: {
schema: 'public',
auth: {
autoRefreshToken: true,
persistSession: true,
detectSessionInUrl: true
global: {
headers: { 'x-my-custom-header': 'my-app-name' },
const supabase = createClient("", "public-anon-key", options)

API schemas

import { createClient } from '@supabase/supabase-js'

// Provide a custom schema. Defaults to "public".
const supabase = createClient('', 'public-anon-key', {
db: { schema: 'other_schema' }

By default the API server points to the public schema. You can enable other database schemas within the Dashboard. Go to Settings > API > Schema and add the schema which you want to expose to the API.

Note: each client connection can only access a single schema, so the code above can access the other_schema schema but cannot access the public schema.

Custom fetch implementation

import { createClient } from '@supabase/supabase-js'

const supabase = createClient('', 'public-anon-key', {
global: { fetch: fetch.bind(globalThis) }

supabase-js uses the cross-fetch library to make HTTP requests, but an alternative fetch implementation can be provided as an option. This is most useful in environments where cross-fetch is not compatible (for instance Cloudflare Workers).