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.1.3-alpha.6 to 1.1.3-alpha.7

2

package.json
{
"name": "next-persist",
"version": "1.1.3-alpha.6",
"version": "1.1.3-alpha.7",
"description": "Bridging the gap between client-side persistence and server-side rendering",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -73,3 +73,3 @@ <p align="center">

To add `<NextPersistWrapper />`, `getStorage`, and `getCookie` to your project, follow these steps.
To add `<NextPersistWrapper />`, `getLocalStore`, and `getCookieStore` to your project, follow these steps.

@@ -105,16 +105,16 @@ ---

3. If utilizing localStorage to persist client-state:<br>
Import `{ getStorage }` into your reducer(s) you plan to persist.
Import `{ getLocalStore }` into your reducer(s) you plan to persist.
```
// yourReducer.js
import { getStorage } from 'next-persist'
import { getLocalStore } from 'next-persist'
```
4. If utilizing cookies to persist client-state:<br>
Import `{ getCookie }` into your frontend at the top level of your Next.js app as well as into any reducer(s) you plan to persist.
Import `{ getCookieProps }` into your frontend at the top level of your Next.js app as well as importing `{ getCookieStore }` into any reducer(s) you plan to persist.
```
// _app.js
import { getCookie } from 'next-persist/src/next-persist-cookies'
import { getCookieProps } from 'next-persist'
// yourReducer.js
import { getCookie } from 'next-persist/src/next-persist-cookies'
import { getCookieStore } from 'next-persist'
```

@@ -181,7 +181,7 @@

In each reducer file we need to import `getStorage` from `'next-persist'` or or `getCookies` from `'next-persist/src/next-persist-cookies'`.
In each reducer file we need to import `getLocalStore` or `getCookieStore` from `'next-persist'`.
Declare a constant and assign it the value of the evaluated result of calling `getStorage` or `getCookies` method.
Declare a constant and assign it the value of the evaluated result of calling `getLocalStore` or `getCookieStore` method.
`getStorage` or `getCookies` takes two arguments:
`getLocalStore` or `getCookieStore` takes two arguments:

@@ -197,5 +197,5 @@ - a string: the reducer key that is saved in storage

import * as types from '../constants/actionTypes';
import { getStorage } from 'next-persist';
import { getLocalStore } from 'next-persist';
// or
// import { getCookies } from 'next-persist/src/next-persist-cookies'
// import { getCookieStore } from 'next-persist'

@@ -209,5 +209,5 @@ const initialState = {

const persistedState = getStorage('reducerOne', initialState);
const persistedState = getLocalStore('reducerOne', initialState);
// or
// const persistedState = getCookies('reducerOne', initialState);
// const persistedState = getCookieStore('reducerOne', initialState);

@@ -232,3 +232,3 @@

In this example we invoke `getCookie` in `getInitialProps` and it will return back an object holding all the persisted state values, saved under the key of their reducer name.
In this example we invoke `getCookieProps` in `getInitialProps` and it will return back an object holding all the persisted state values, saved under the key of their reducer name.

@@ -238,4 +238,4 @@ ```

MyApp.getInitialProps = async (ctx) => {
const cookieState = getCookie(ctx);
MyApp.getInitialProps = async ({ ctx }) => {
const cookieState = getCookieProps(ctx);
return {

@@ -242,0 +242,0 @@ pageProps: cookieState,

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