Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
next-redux-store
Advanced tools
Next integration with Redux.
Features:
npm i next-redux-store
import { AppProps } from 'next/app';
import { StoreProvider } from 'next-redux-store';
import { makeStore } from 'modules/makeStore';
// Note that makeStore must accept preloadedState as an argument
// See example (https://github.com/fakundo/next-redux-store/blob/master/packages/docs/modules/makeStore.tsx#L4)
export default function _App(appProps: AppProps<any>) {
const { Component, pageProps } = appProps;
return (
<StoreProvider makeStore={makeStore} appProps={appProps}>
<Component {...pageProps} />
</StoreProvider>
);
}
import { makeStore } from 'modules/makeStore';
import { createGetInitialProps } from 'next-redux-store/server';
const getInitialState = async (ctx, appProps) => {
const store = makeStore();
// Fill the store considering the App props and Document context
// See example (https://github.com/fakundo/next-redux-store/blob/master/packages/docs/pages/_document.tsx#L14)
return store.getState();
}
export default class _Document extends Document {
static getInitialProps = createGetInitialProps(getInitialState);
render() {
...
}
}
import { serverSideState } from 'next-redux-store/server';
export const getStaticProps = async () => {
const store = makeStore();
// Fill the store
const initialState = store.getState();
return {
props: {
...serverSideState(initialState),
},
};
}
import { ProviderProps } from 'react-redux';
interface StoreProviderProps extends Omit<ProviderProps, 'store'> {
appProps: AppProps<any>;
makeStore: (preloadedState: any | undefined) => any;;
}
createGetInitialProps creates a function that returns initial props for the Document, providing initialState of store for the App.
type CreateInitialState = (ctx: DocumentContext, appProps: AppProps<any> | undefined) => any;
const createGetInitialProps: (createInitialState: CreateInitialState) => (ctx: DocumentContext) => DocumentInitialProps;
createInitialState can accept two parameters: App props and Document context.
serverSideState accepts state of the store and returns page props.
HYDRATE returns name of the hydration action.
MIT
FAQs
Next integration with Redux
The npm package next-redux-store receives a total of 281 weekly downloads. As such, next-redux-store popularity was classified as not popular.
We found that next-redux-store demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.