Socket
Book a DemoInstallSign in
Socket

cookies-next

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cookies-next

Set, Get, Remove cookies on both client and server side with Next.js

6.1.0
latest
Source
npmnpm
Version published
Weekly downloads
596K
-2.25%
Maintainers
1
Weekly downloads
 
Created

What is cookies-next?

The cookies-next npm package is a utility for handling cookies in Next.js applications. It provides simple methods to set, get, and delete cookies both on the client and server side.

What are cookies-next's main functionalities?

Set a Cookie

This feature allows you to set a cookie with a specified name and value. You can also set additional options such as maxAge. The code sample demonstrates how to set a cookie both on the server side and client side.

const { setCookie } = require('cookies-next');

// On the server side
export function handler(req, res) {
  setCookie('token', '123456', { req, res, maxAge: 60 * 60 * 24 });
  res.end('Cookie set');
}

// On the client side
setCookie('token', '123456', { maxAge: 60 * 60 * 24 });

Get a Cookie

This feature allows you to retrieve the value of a specified cookie. The code sample demonstrates how to get a cookie both on the server side and client side.

const { getCookie } = require('cookies-next');

// On the server side
export function handler(req, res) {
  const token = getCookie('token', { req, res });
  res.end(`Token: ${token}`);
}

// On the client side
const token = getCookie('token');
console.log(`Token: ${token}`);

Delete a Cookie

This feature allows you to delete a specified cookie. The code sample demonstrates how to delete a cookie both on the server side and client side.

const { deleteCookie } = require('cookies-next');

// On the server side
export function handler(req, res) {
  deleteCookie('token', { req, res });
  res.end('Cookie deleted');
}

// On the client side
deleteCookie('token');

Other packages similar to cookies-next

Keywords

js

FAQs

Package last updated on 15 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.