简体   繁体   中英

How to persist logged in user in Next.js

How can I possibly persist user data even after refresh? I was thinking about storing it inside local storage but that mean flash of unauthenticated content or storing it in cookie, but this would be very problematic when working with redux. I'm looking for a solution that will work with redux and will not cause unauthorized page content to show up.

You can use an npm package called Next Iron Session . It works really well with nextjs api and getServersideProps. It's based on iron by Hapijs

You can use jwt in your Next.js project.

Please refer to this

And there is a way to integrate Auth0 as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM