Supabase & ReactJS - Authentication

Hi,
I implemented this authentication method into my React app: https://github.com/MoralisWeb3/Moralis-JS-SDK/tree/main/demos/supabase-auth

It works at first but authentication lost on new renders, any solution?
Thanks.

There was something like this to check authentication into v1;
โ€œconst {isAuthenticated} = useMoralis()โ€

Hey @blockchaindeveloper,

Can you clarify what do you mean by the authentication lost on new renders?

Also Looks like this project is using Moralis v2, which does not contain isAuthenticated code that we have in v1

Hey @YosephKS ,
Basically, we can check if authenticated or not in moralis-v1 but how to handle this in moralis-v2 with Supabase auth? If i refresh the page or any state changes after first authentication the session is disappearing.
If there was Supabase&React tutorial, it will be beneficial.

Hey @blockchaindeveloper,

For Moralis V2, we just provide the API for authentication to verify, but for session youโ€™ll need to set that up yourself as we donโ€™t provide on that out of the box

I see here that we have tutorial on how to setup Supabase JWT for the session https://docs.moralis.io/authentication-api/evm/integrations/supabase-nodejs#store-a-user-in-supabase-and-sign-a-jwt-with-the-user, by any chance you have take a look at this?

I already implemented this tutorial to my existed dApp succesfully but the problem is;
this part is creating just a temporary session not persistent:

_supabaseAuthenticated = supabase.createClient(SUPABASE_URL, SUPABASE_PUBLIC_ANON_KEY, { global: { headers: { Authorization: Bearer ${user.token}, }, }, });

If the user refresh the page or any state changes, user has to be authenticate again which is not a good practice.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.