Arguments for/against using AuthContext provider
In some beginner react tutorials I remember the need to set up AuthContext, specifically when rolling my own auth with mongodb. Im a little hazy but I would send user/pass to mongo, check hash and verify, then store returned user info into AuthContext with a dispatch.
In all the t3 tutorial videos i do not see reference to using AuthContent. Could some more experienced devs chime in as to why I would or would not want to use AuthContext an react context api when building apps with T3?
5 Replies
next-auth uses a context provider
look in _app.tsx of a t3 app
so with using clerk/firebase/supabase its standard to not use AuthContext, because its "so easy" to call the client?
or is it because we use something like <ClerkProvider> which is the same as an <AuthContext> provider...
I haven't read the source code for any of those but im 99% sure they also use context under the hood
<AuthContext> doesnt mean anything, its just a name
i think this is a great read for anyone looking this up in the future...
Clerk
Next.js 13 Routes Part 2: Implementing Protected Routes
Learn how to create protected routes using React Context as well as how using Clerk makes this process easier.