Skip to main content

Supabase Third-Party Auth Integration

Category
Integrations
Published

Integrate Clerk with Supabase as a third-party authentication provider.

Clerk is now supported as a Supabase third-party authentication provider. This first-class integration allows Supabase to accept Clerk-signed session tokens, removing the need to create a custom JWT template and generate a specific token when interacting with Supabase's APIs.

Now, all you need to do is pass Clerk's session token to Supabase's client:

import { createClient } from '@supabase/supabase-js'
import { auth } from '@clerk/nextjs/server'

const supabase = createClient(
  process.env.NEXT_PUBLIC_SUPABASE_URL!,
  process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
  {
    async accessToken() {
      return (await auth()).getToken()
    },
  },
)

Enable the integration

To get started with Clerk and Supabase:

  1. Visit the Clerk dashboard and go through the setup flow
  2. Copy your Clerk instance domain into Supabase's Third-party auth settings

For more information, visit the Supabase Integration documentation page. We can't wait to see what you build with Clerk and Supabase!

Contributors
Ben Werner
Bryce Kalow
Mery Kaftar