Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cookies-next

Package Overview
Dependencies
Maintainers
1
Versions
30
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

  • 5.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
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

FAQs

Package last updated on 08 Nov 2024

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc