Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useSupabaseClient vs useSupabaseAuthClient? #124

Closed
franciscolourenco opened this issue Dec 4, 2022 · 3 comments
Closed

useSupabaseClient vs useSupabaseAuthClient? #124

franciscolourenco opened this issue Dec 4, 2022 · 3 comments
Labels
question Further information is requested

Comments

@franciscolourenco
Copy link

What is the difference between these? They seem to return the same client with the same options?

@franciscolourenco franciscolourenco added the question Further information is requested label Dec 4, 2022
Copy link
Collaborator

larbish commented Dec 5, 2022

As it is explained in the doc, useSupabaseAuthClient is dedicated to authentification purpose only. It won't be recreate if your token expires, it is used in the client plugin to listen to onAuthStateChange events. If you want to fetch data from the db, use the useSupabaseClient instead. You can dig into the code (composables and plugins folder) to understand how it works.

@larbish larbish closed this as not planned Won't fix, can't repro, duplicate, stale Dec 5, 2022
@franciscolourenco
Copy link
Author

I did dig through the code and it's still not completely clear what/why is happening with the session being shared between the server and frontend supabaseClients.

From the outside it is quite confusing that both composables are returning different instances of the supabaseClient, and the docs don't do a sufficient job at explaining why.

Would it be a possibility use supabase.auth.setSession({refresh_token, access_token}) instead of recreating the supabase client every time the access token changes? That way useSupabaseAuthClient could be deprecated.

Copy link
Collaborator

larbish commented Dec 6, 2022

Thank you for your feedback. I'v made the choice to create the useSupabaseAuthClient in order to fix the #114 issue while keeping client and server session/user synced. I'd be really pleased if you find a more appropriate way to handle it. Feel free to propose something in a PR, I'll be happy to review !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants