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.2 to 1.1.3-alpha.0

index.js

9

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

@@ -27,8 +27,13 @@ "main": "src/next-persist.js",

"homepage": "https://github.com/oslabs-beta/next-persist#readme",
"dependencies": {
"devDependencies": {
"cookie": "^0.4.1",
"jest": "^26.6.3",
"js-cookie": "^2.2.1",
"react": "^17.0.2",
"react-redux": "^7.2.3"
},
"peerDependencies": {
"react": ">=16.8.3",
"react-redux": ">=7.1.0"
}
}

@@ -29,6 +29,6 @@ <p align="center">

<td width="60%">
<p>What is next-persist? next-persist is a lightweight NPM package developed to simplify the process of storing and reconciling non-critical persistent client data while retaining the benefits of server side rendering and static site generation through Next.js.</p>
<p>Wouldn't it be nice to gain the benefits of Next.js while still providing the users with some sort of persistent dynamics? All without worrying about the architecture and costs of additional database management systems?
<br>
<p>'What is next-persist?' Well, next-persist is a lightweight NPM package developed to simplify the process of storing and reconciling non-critical persistent client state while retaining the benefits of server side rendering and static site generation provided by Next.js.</p>
<p>Wouldn't it be nice to gain the benefits of Next.js while still providing the users with some sort of dynamic state persistence? How about without worrying about the design and added costs of additional database management systems?
</p>
<p>
Well now you can! next-persist provides a simple solution for your dynamic, isomorphic web applications. Just import next-persist, set up a quick config and incorporate our functions. We do the rest, delivering you the benefits of server side rendering and persistent client data.

@@ -245,3 +245,3 @@ </p>

## **WARNING** - NEVER STORE UNENCRYPTED PERSONAL DATA TO CLIENT STORAGE
### **WARNING** - NEVER STORE UNENCRYPTED PERSONAL DATA TO CLIENT STORAGE

@@ -248,0 +248,0 @@ ---

@@ -13,31 +13,30 @@ /**

import { Component } from 'react';
import { connect } from 'react-redux';
import { setCookie } from './next-persist-cookies';
import { setStorage } from './next-persist';
import { useEffect } from 'react';
import { useSelector } from 'react-redux';
import { setCookieStore } from './next-persist-cookieStore';
import { setLocalStore } from './next-persist-localStore';
const mapStateToProps = (state) => ({
state,
});
const NextPersistWrapper = (props) => {
const state = useSelector((state) => state);
class NextPersistWrapper extends Component {
render() {
useEffect(() => {
// determines method to persist state
let method;
if (this.props.wrapperConfig.method === 'localStorage') {
method = setStorage;
} else if (this.props.wrapperConfig.method === 'cookies') {
method = setCookie;
if (props.wrapperConfig.method === 'localStorage') {
return setLocalStore;
} else if (props.wrapperConfig.method === 'cookies') {
return setCookieStore;
}
const { allowList } = this.props.wrapperConfig;
const { allowList } = props.wrapperConfig;
const nextPersistConfig = {};
// if no allowlist provided save all state to their corresponding keys
// if no allowList - save all state to their corresponding keys
if (!allowList) {
const key = Object.keys(this.props.state)[0];
const key = Object.keys(state)[0];
nextPersistConfig[key] = [];
method(nextPersistConfig, this.props.state[key]);
method(nextPersistConfig, state[key]);
}
// if allowlist exists pass subconfigs of allowed reducers into storage method
// if allowList - pass subconfigs of allowed reducers into storage method
else {

@@ -47,12 +46,10 @@ const allowedReducers = Object.keys(allowList);

nextPersistConfig[allowedReducer] = allowList[allowedReducer];
method(nextPersistConfig, this.props.state[allowedReducer]);
method(nextPersistConfig, state[allowedReducer]);
});
}
return this.props.children;
}
}
}, [state]);
// connects wrapper to redux store
const PersistWrapper = connect(mapStateToProps)(NextPersistWrapper);
return props.children;
};
export default PersistWrapper;
export default NextPersistWrapper;
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