Dettlaff
Dettlaff

Reputation: 210

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.

Upvotes: 1

Views: 6890

Answers (2)

hotcakedev
hotcakedev

Reputation: 2514

You can use jwt in your Next.js project.

Please refer to this

And there is a way to integrate Auth0 as well.

Upvotes: 2

Pranta
Pranta

Reputation: 3695

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

Upvotes: 3

Related Questions