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

next-persist

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-persist - npm Package Compare versions

Comparing version 1.0.9 to 1.1.0

2

package.json
{
"name": "next-persist",
"version": "1.0.9",
"version": "1.1.0",
"description": "Bridging the gap between client-side persistence and server-side rendering",

@@ -5,0 +5,0 @@ "main": "src/next-persist.js",

@@ -41,9 +41,20 @@ /**

arguments:
req (object) - request object from the context object from Next.js data-fetching methods
if application is running server-side:
req (object) - request property from the context object from Next.js data-fetching methods
if application is running client-side:
req (boolean) - should be 'false'
state (object) - object from application containing state
cookieName (string) - the name of the cookie specified in setCooking config
*/
// if application is running server-side, parse and return cookie from request object
// if application is running client-side, parse and return cooking from document object
nextPersistCookie.getCookie = (req) => cookie.parse(req ? req.ctx.req.headers.cookie || '' : document.cookie);
nextPersistCookie.getCookie = (req, state, cookieName) => {
// if application is running client-side, parse and return cookie from browser
if (!req) {
const stateFromCookie = Cookie.get(cookieName);
return stateFromCookie ? JSON.parse(stateFromCookie) : state
} // if application is running server-side, parse and return cooking from request body
else return cookie.parse(req.ctx.req.headers.cookie || '');
}
module.exports = nextPersistCookie;
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