Next.js Discord

Discord Forum

How to store user info after login in which can be accessible from the server pages & action?

Unanswered
Philippine Crocodile posted this in #help-forum
Open in Discord
Philippine CrocodileOP
I am using a separate backend with my Next js application. I am using JWT Access token & Refresh token based authentication.

I have created a server action - ApiRequestHandler for handling all the request to my separate backend which I am using on both client & server pages.

Also I have a server action to perform login. Now I can store the userinfo returned in my login method in the client side using context. But how can I store this userinfo in the server side so that I can use on server pages & server actions?

4 Replies

@Jboncz Cookies are available to get in server actions, why not just grab it on the backend to see who they are?
Philippine CrocodileOP
Didn't get it. Did you mean to store the userinfo in the cookies?
I store the data in my JWT as part of the payload.
As long as its not absurd amount of data you want to store, and if it is, store something identifiable to the user and then do a lookup if needed