JavaScript: Initializing

Create a new client for use in the browser.

Parameters

Examples

Create Client

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

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

With Additional Parameters

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

  const options = \{
    schema: 'public',
    headers: \{ 'x-my-custom-header': 'my-app-name' \},
    autoRefreshToken: true,
    persistSession: true,
    detectSessionInUrl: true,
  \}
  const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key', options)

API schemas

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

  const options = \{
    schema: 'public',
    headers: \{ 'x-my-custom-header': 'my-app-name' \},
    autoRefreshToken: true,
    persistSession: true,
    detectSessionInUrl: true,
  \}
  const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key', options)

Custom Fetch Implementation

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

  const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key', \{
    fetch: fetch.bind(globalThis),
  \})