Skip to content

Avoid using @supabase/ssr with third-party authentication #103

@sixelasacul

Description

@sixelasacul

Improve documentation

Link

Perhaps in this page: https://supabase.com/docs/guides/auth/server-side, or this one: https://supabase.com/docs/guides/auth/third-party/overview

Describe the problem

I was using the @supabase/ssr package for a PoC I'm building with TanStack Start, so I thought of using the SSR specific package to use Supabase, as described here: https://supabase.com/docs/guides/auth/server-side. Later, I wanted to use an alternative auth (better-auth) while still using Supabase. Thus, I was following the following documentation to change my configuration: https://supabase.com/docs/guides/auth/third-party/overview. I first didn't notice that the examples were using @supabase/supabase-js package, but I thought that it should still work for this use case. Unfortunately it did not, and it was throwing some misleading error:

@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.onAuthStateChange is not possible

After looking at the createServerClient implementation, I figured that I shouldn't be using the @supabase/ssr if I'm using a third-party authentication:

client.auth.onAuthStateChange(async (event: AuthChangeEvent) => {
.

Describe the improvement

I think either of the pages I mentioned above can have a note saying that the @supabase/ssr package should not be used with third-party authentication, and default to the @supabase/supabase-js. Unless there's another benefit for using this package except the Supabase first-party auth, in which case the client should be updated to not call supabase.auth.onAuthStateChange.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions