JSPM

  • Created
  • Published
  • Downloads 234221
  • Score
    100M100P100Q175121F
  • License MIT

A set of cookie helpers for Next.js

Package Exports

  • nookies

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (nookies) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

XO code style

nookies 🍪 🍪 🍪

A collection of cookie helpers for Next.js

  • SSR support, for setter, parser and destory
  • super light
  • perfect for authentication

Setting and destorying cookies also works on server-side.

Quick start

// Parse
parseCookies(ctx)

// Set
setCookie(ctx, 'token', token, {
   maxAge: 30 * 24 * 60 * 60,
   path: '/'
})

// Destory
destroyCookie(ctx, 'token')

Reference

parseCookies(ctx, options)

  • ctx: Next.js context
  • options:
    • decode: a custom resolver function (default: decodeURIComponent)

setCookie(ctx, name, value, options)

  • ctx: (Next.js context)
  • name: cookie name
  • value: cookie value
  • options:
    • domain
    • encode
    • expires
    • httpOnly
    • maxAge
    • path
    • sameSite
    • secure

destroyCookie(ctx, name)

  • ctx: (Next.js context)
  • name: cookie name

License

MIT