-
Notifications
You must be signed in to change notification settings - Fork 1k
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
chore: Updates Supabase readme, docs and tests for sign up with options and user/session #7765
chore: Updates Supabase readme, docs and tests for sign up with options and user/session #7765
Conversation
16 replays were recorded for 4ff023f. 16 PassedrequireAuth graphql checks
|
Just dropping this here for when we get around to SSR with render modes and using supabase cookies |
@dthyresson I think some of the existing docs are incorrect. I can't comment on all the relevant lines but here are my notes:
These changes would have to be replicated in the readme. |
Thanks for catching. Fixing.
For these, I referenced the Supabase docs, such as: https://supabase.com/docs/reference/javascript/auth-getsession
I'm not sure if it needs to be in a useEffect(). I'll ask Supabase. |
Turns out, they do need to be in a useEffect() as shown in this Remix example: https://supabase.com/docs/guides/auth/auth-helpers/remix const { env, session } = useLoaderData<typeof loader>()
const fetcher = useFetcher()
const [supabase] = useState(() =>
createBrowserClient<Database>(env.SUPABASE_URL, env.SUPABASE_ANON_KEY)
)
const serverAccessToken = session?.access_token
useEffect(() => {
const {
data: { subscription },
} = supabase.auth.onAuthStateChange((event, session) => {
if (session?.access_token !== serverAccessToken) {
// server and client are out of sync.
// Remix recalls active loaders after actions complete
fetcher.submit(null, {
method: 'post',
action: '/handle-supabase-auth',
})
}
})
return () => {
subscription.unsubscribe()
}
}, [serverAccessToken, supabase, fetcher]) @jtoar I've made those doc updates. Thanks! |
This PR:
Addresses #6146 via documentation (and the prior v2 upgrades).