Build Single page applications with React and Django Part 9 — Access Redux on the Next.js page-level

Introduction
This series is to build a SPA with ReactJS and Django.
We have discussed a few topics from part 1 to part 7. In part 8, we began to use Next.js and export static full pages for overcoming drawbacks of the CSR(Client-Side Rendering) and improving the performance.
On the frontend side, there are several kinds of tools to improve the project that we have talked like Redux, middleware for Redux(Thunk, Saga, etc), and Jest. The page-level Redux accessing is an important part of improving CSR.
About this series
The target of this series is to build a ReactJS single page application(SPA) with Django API server and deploy on Heroku.
- Part 1: Deploy Django application to Heroku and migrate PostgreSQL
- Part 2: Connect React App with Django App
- Part 3: Use JWT with DRF and tests endpoints on Travis-CI
- Part 4: Create Endpoints to Manipulate Resources
- Part 5.1: Exchange Facebook’s access token to JWT from Django/DRF
- Part 5.2: Exchange Github’s access token to JWT from Django/DRF
- Part 6: Create Django Application’s sitemap on Heroku for SEO
- Part 7: How to Refactor Function Components with HOC?
- Part 8: Static Rendering with Next.js and Django on Heroku
- Part 9: this article
- Part 10: Improve SEO with Pyppeteer in Django
- Part 11: Theming with Redux and styled-component
Use redux-promise-middleware as middleware
In this article, we will integrate next-redux-wrapper into the project in order to access Redux at the page-level. For async actions, the official document recommends that we can use redux-promise-middleware to dispatch async actions.
1. Create a Next.js project
- You can use the following npx command to create a default project folder for the Next.js project which also provides page-level Redux supports
create-nrs-web- Answer the questions with the following answers. We will migrate the middleware from react-thunk to redux-promise-middleware

2. Installation
- Install the package with the following command.
npm install --save redux-promise-middleware- Use redux-promise-middleware as the middleware in store/store.js






