Redskinsjo
Redskinsjo

Reputation: 452

next 14 get cookie in server component after redirection from route handler

I started nextjs few days ago.

I wish to get the cookie i created in route handler with cookies().set() and get the cookie newly created in the redirect page server component with cookies().get().

However, the cookie seems to only be available in the client. I was expecting NextJs to be able to get the cookie in the server side.

Do I have wrong expectations as it would not be possible, or am I doing something not right ?

Upvotes: 0

Views: 691

Answers (1)

Redskinsjo
Redskinsjo

Reputation: 452

i found the solution.

by creating a response and res.cookies.set(), you can add your cookie that you first have set with cookies().set() and stored in a variable with cookies().get()

Upvotes: 0

Related Questions