What Supabase initialization to use for Next.js with React
I'm confused as to what to use between the default
createClient and the createBrowserClient/createServerClient from the @supabase/ssrpackage.3 Replies
There are docs around all of them which shows where you use what. The names too kind of give you ȧ clue. What are you confused about?
So far, I've only had experience with the Flutter package, which only provides the default
createClient.
This is my first Next.js project, so I just used the basic package supabase/supabase-js and didn't really look at the auth part of the docs for Next.js.
What's confusing me is that the auth flow strictly only uses the supabase/ssr package (at least that's what I understand).
I'm confused by the more convoluted/complex setup requirements, as the default works perfectly fine, and I just can't wrap my head around why the supabase/ssris preferred.When you start trying to use the client on the server you will notice it's not possible as the default
createClient relies on localStorage in the browser which is not accessible to any server side code. The ssr package is built to help with this as it stores the session inside of a cookie that is shared between the client and the server. I think you should first try and understand how Nextjs works and then you will understand why the need for ssr package.