🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

nookies

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nookies

A set of cookie helpers for Next.js

2.5.2
latest
Source
npm
Version published
Weekly downloads
232K
-3%
Maintainers
1
Weekly downloads
 
Created

What is nookies?

Nookies is a simple utility for handling cookies in Next.js applications. It provides a straightforward API for setting, getting, and destroying cookies on both the client and server sides.

What are nookies's main functionalities?

Set a Cookie

This feature allows you to set a cookie in a Next.js application. The code sample demonstrates how to set a cookie named 'cookieName' with a value of 'cookieValue' that expires in 30 days.

const nookies = require('nookies');

// In a Next.js API route or getServerSideProps
export function handler(req, res) {
  nookies.set({ res }, 'cookieName', 'cookieValue', {
    maxAge: 30 * 24 * 60 * 60,
    path: '/',
  });
  res.end('Cookie set');
}

Get a Cookie

This feature allows you to retrieve a cookie in a Next.js application. The code sample demonstrates how to get the value of a cookie named 'cookieName'.

const nookies = require('nookies');

// In a Next.js API route or getServerSideProps
export function handler(req, res) {
  const cookies = nookies.get({ req });
  res.end(`Cookie value: ${cookies.cookieName}`);
}

Destroy a Cookie

This feature allows you to destroy a cookie in a Next.js application. The code sample demonstrates how to destroy a cookie named 'cookieName'.

const nookies = require('nookies');

// In a Next.js API route or getServerSideProps
export function handler(req, res) {
  nookies.destroy({ res }, 'cookieName');
  res.end('Cookie destroyed');
}

Other packages similar to nookies

Keywords

cookie

FAQs

Package last updated on 21 Jan 2021

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