fix: cache supabase browser client as singleton to prevent recreation…#59
fix: cache supabase browser client as singleton to prevent recreation…#59MayurKharat0390 wants to merge 3 commits into
Conversation
|
@MayurKharat0390 is attempting to deploy a commit to the aditthyass' projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Hey @MayurKharat0390 , thank you for the contribution I noticed that there are merge conflicts in this PR Please sync your branch with the latest Let me know if you need any assistance while resolving them. Thanks again for the contribution ⭐ |
# Conflicts: # src/lib/supabase.ts
|
Hey @AditthyaSS, I have synced the branch with the latest Additionally, I noticed that the Everything compiles successfully and is ready for your review! ⭐ |
Description
This Pull Request implements a singleton caching pattern for the Supabase browser client inside
src/lib/supabase.ts.The Problem
In the original implementation, the
getSupabaseBrowserClient()function initialized a brand new Supabase client instance usingcreateClient()on every single invocation. Because React components, hooks, and context providers call this helper frequently throughout the lifecycle of the application:The Solution
cachedBrowserClientto cache the initialized client.getSupabaseBrowserClient()to check for the cached instance first and return it if present.Closes