NextJS with Redux and Material-UI example is a boilerplate project that demonstrates how to combine Next.js server-side rendering with Redux state management and Material-UI components in a single starter application.
What is NextJS with Redux and Material-UI example?
This is a boilerplate/example project for building Next.js applications with Redux and Material-UI. It takes a minimal counter app as its use case and shows how to initialize Redux on the server via getInitialProps, pass the initial state to the client, and manage client-side dispatches. The project is authored by GitHub user joaopaulomoraes and is licensed under CC0 (public domain).
Key Features
- SSR + Redux integration — Uses
next-redux-wrapperto connect a Redux store to Next.js pages and supports server-side rendering of Redux state. - Client/server store separation — The
store.jsfile creates a new Redux store for each server request to avoid data mixing between users, and reuses the same store on the client. - Material-UI included — The project includes Material-UI, so UI components like buttons and layout are built with MUI without extra setup.
- getInitialProps data fetching — Demonstrates server-side data initialization by dispatching an increment action before the first render, so the counter starts at 1 instead of 0.
- Hot reload dev server — Run
yarn devto serve at http://localhost:3000 with hot reload during development. - Simple example structure — A single page at
pages/index.jsmaps to the/route, making the code easy to read and modify.
Who is it for?
- Next.js developers who want a working reference for integrating Redux with SSR.
- React developers transitioning to Next.js and needing a minimal example of universal state management.
- Learners who want to understand how
next-redux-wrapperandgetInitialPropswork together.
What can you do with NextJS with Redux and Material-UI example?
- Build a foundation: Use the boilerplate as a starting point for any Next.js app that needs Redux and Material-UI, simply replacing the counter with your own features.
- Learn SSR patterns: Study how the same Redux store is initialized on the server and hydrated on the client, and how the
isServerflag changes dispatch behavior. - Compare approaches: The README also points to the alternative package
next-connect-redux, which offers similar features, if you want to explore other integration options.
How does NextJS with Redux and Material-UI example work?
Clone the repository, run yarn install, then yarn dev to launch the dev server at http://localhost:3000. The example counter is initialized to 1 on the server render and then updates from client dispatches. The store.js file separates store creation per environment.
FAQ
What does the counter example demonstrate?
The counter initializes at 0, but because getInitialProps dispatches an increment on the server, the first rendered value is 1. Subsequent clicks dispatch actions on the client, and a flag above the counter shows whether the dispatch came from the server or the client.
How do I install and run this project?
Clone the repository, run yarn install, then yarn dev. The app will be available at http://localhost:3000 with hot reload.
Is this project free to use?
Yes, the project is released under the CC0 1.0 license, placing it in the public domain.
What is the purpose of separating client and server stores?
On the server, a new Redux store is created for each request so data is not mixed between users. On the client, the same store instance is reused across navigations.
Does this template include Material-UI components?
Yes, Material-UI is included and used to build the UI. The components are styled with MUI, so you can extend them using MUI's theming and styling system.







