Skip to main content

Creating a Supabase Client

We will be creating a client to interact with Supabase using the supabase-js library.

  • Install the supabase-js library

    npm install @supabase/supabase-js
  • Create a new file called utils/supabase.ts and add the following:

    // utils/supabase.ts
    import { createClient } from '@supabase/supabase-js'
    let supabase_url = process.env.NEXT_PUBLIC_SUPABASE_URL || "TODO: Your Supabase URL"let supabase_key = process.env.NEXT_PUBLIC_SUPABASE_KEY || "TODO: Your Supabase Key"
    const getSupabase = (access_token: string) => {  const supabase = createClient(    supabase_url,    supabase_key  )
      supabase.auth.session = () => ({    access_token,    token_type: "",    user: null  })
      return supabase}
    export { getSupabase }
Which frontend SDK do you use?
supertokens-web-js / mobile
supertokens-auth-react