supabase icon indicating copy to clipboard operation
supabase copied to clipboard

Adding the ability to use @nuxtjs/supabase with Clerk

Open 9M6 opened this issue 1 year ago • 2 comments

Is your feature request related to a problem? Please describe.

Clerk is an Authentication as a Service and they provide libraries to delegate authentication, they also integrate well with Supabase, since there're some use-cases where we don't really need Supabase Auth but instead, we require something more complicated and comprehensive.

Clerk provides some libraries, for Vue there's a community-maintained library, but there's no nuxt plugin. I tried to combine the vue-clerk with @nuxtjs/supabase but it did not really work, or it requires some hard-coding, and the use of createClient from the native supabase-js library.

Describe the solution you'd like

In the clerk integration example clerk docks on supabase, we need to pass a Bearer Token to the config of the supabase-js createClient

const supabaseClient = async (supabaseAccessToken) => {
    const supabase = createClient(process.env.NEXT_PUBLIC_SUPABASE_URL, process.env.NEXT_PUBLIC_SUPABASE_KEY, {
      global: { headers: { Authorization: `Bearer ${supabaseAccessToken}` } },
    });
    // set Supabase JWT on the client object,
    // so it is sent up with all Supabase requests
    return supabase;
  };

I think if we could have this ability on the @nuxtjs/supabase library by default that would be awesome. I know we can configure it on our own using the nuxt.config.ts files, but the problem here is that clerk gives a dynamic token depending on the user tho has authenticated, and which must be included every time.

Describe alternatives you've considered

N/A

Additional context

N/A

9M6 avatar Dec 31 '23 12:12 9M6

Have you found a solution to this maybe?

dustin-we avatar Feb 11 '25 11:02 dustin-we

This would be super helpful for my use case too

flock-games avatar Apr 24 '25 15:04 flock-games