Next.js Discord

Discord Forum

Share session between Next y React

Araucanian herring posted this in #help-forum
Open in Discord
Araucanian herringOP
Hello everyone, I have a Next application protected with Keycloak through NextAuth, and I have another React application also with the same Keycloak protected with the official keycloak libraries (keycloak-js and react-keycloak/web), both applications live in the same subdomain. When I log in to Next and then switch to the React app, the user stays logged in as the Keycloak cookies exist, however the other way around, when I log in to React and then switch to Next, it's not recognized the session, I understand that it is because NextAuth has its own cookie and ignores those of Keycloak, my question is:

Is there a way for NextAuth to recognize Keycloak cookies so as not to lose the user's session between applications?
Or what other solution comes to your mind to propagate the session?

0 Replies