admin管理员组文章数量:1188827
Trying to persist user login using cookies but it just won't work.
I am developing an application in NextJS 14.2.23 and I am using zustand for state management. When the user logs in, I authenticate using my backend and get a token in response. This token is encrypted and stored in cookies. I was using Next 12 earlier and when the user would refresh the page, I would use getInitialProps to get the cookie and gather the user data from backend using the token in the cookie. I recently upgraded to NextJS 14 and tried to the same using layout.tsx async function. The data is fetched on the server side during the initial load but when I try to persist the same in the zustand store, it does not behave the way I expect it to.
Can someone guide me what would be the best approach to persist the user login in the given scenario?
本文标签: typescriptPersist sessions in Next JS 14 using cookiesStack Overflow
版权声明:本文标题:typescript - Persist sessions in Next JS 14 using cookies - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738361718a2080855.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论