Explore Templates

Global State Management

To manage global states in our application, we have created a custom globalStateProvider using react context Api, using which you can manage global states in the application..

How to create Global States

First you need to create Reducers, that is a basically pure JS functions which take in the previous state and an action and return the newly updated state.

  1. First you need to create induvidual component based reducer function.
  2. Then you need to add your individual reducer and initialState to the rootReducer function in "/src/context/rootReducer.js", which will automatically connect to our GlobalStateProvider, which is our custom store function.
  3. Then you need to wrap your Next.js rootLayout with our custom store function GlobalStateProvider from "src/context/GlobalStateProvider.js".
How to use Global States

You can use Global States in the following ways: