Great question — answering as the UphillTech team:
If you have a custom App with getInitialProps then the Automatic Static Optimization that Next.js provides will be disabled for all pages. True, if you follow this approach. Is there a better way ? Yes, you can create a Redux Provider as a wrapper and wrap the component you need, the redux context will be automatically initialized and provided within that component. Example: const IndexPage = () => { // Implementation const dispatch = useDispatch() // ... // ... return <Something />; } IndexPage.getInitialProps = ({ reduxStore }) => { // Implementation const { dispatch } = reduxStore; // ... // ... } export default withRedux(IndexPage) You have now the possibility to use Redux only for the...
Full answer by ddon-90: https://stackoverflow.stackexchange.com/a/60632610 (CC BY-SA 4.0).
Need it done for your business? UphillTech.