Authentication
Using Supabase (reccommended)
Follow these instructions to set up supabase in your project
Set
requireAuthtotrueinconfig.js. This will force the user to login before accessing the app
Not Using Supbase
Open
AuthProvider.tsRe-implement the
useEffectusingonAuthStateChange, and setuserIDandisAuthInitialized
useEffect(() => {
supabase.auth.onAuthStateChange((_event, session) => {
if (session) {
setUserId(session.user.id)
} else {
setUserId("")
}
setIsAuthInitialized(true)
})
}, [])
Re-implement the functions
handleSignUp,handlesignIn,handlesignOut, andhandlesignInGuestinAuthProvider.tsx
Last updated