question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Set (send) cookies server side like in Express.js via ctx.res.cookie

See original GitHub issue

Feature request

There is no easy way to send cookies from the server in next.js, You can get cookies via ctx.req.headers.cookie so one would expect to send them via ctx.res.[headers].cookie in getInitialProps similar to express.js

Is it something on your radar? Or can you recommended a third party lib to do that?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
slava-lucommented, Apr 14, 2020

You can create a simple function for yourself or just use the native node.js implementation.

I know that I can create it myself as well as I can do SSR myself. But the question was different.

1reaction
slava-lucommented, Apr 13, 2020

Try next-cookies

It only reads cookies but does not send them in http response. This lib has 4 lines of code.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I set cookie in node js using express framework?
use(express. cookieParser()); // set a cookie app. use(function (req, res, next) { // check if client sent cookie var cookie = req. cookies....
Read more >
Setting and Using Cookies with a Node.js / Express Server
In this blog I'll be setting up a server using Node.js and Express, and use it to set and receive cookies. To test...
Read more >
Cookies | NestJS - A progressive Node.js framework
Nest is a framework for building efficient, scalable Node.js server-side ... Cookies. An HTTP cookie is a small piece of data stored by...
Read more >
How to Send Cookies from Express to a Front-End Application ...
In this article, I would be explaining how to send cookies from an Express app via an express-session package to the front end...
Read more >
Koa - next generation web framework for node.js
ctx.cookies.set(name, value, [options]). Set cookie name to value with options :.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found