Skip to content
Advertisement

Firebase does not authenticate when using next auth

I’m using next-auth with firebase adapter. Everything is working fine in terms of saving users in database, but something is not working in terms of authentication.

JavaScript

My users can log in, but are not authenticated.

JavaScript

The Observer returns ‘no user’, but I’m logged in.

Advertisement

Answer

You’re not seeing a logged in user because the firebase auth is being done on the server side, and not the client side.

You should try passing the customToken to the session, then use it on the client side to sign in the user to firebase auth.

You would also want to wrap the useSession hook in a custom hook like below and use that instead of useSession.

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement