use redux in gatsby
npm install --save gatsby-plugin-react-redux react-redux redux
//
yarn add gatsby-plugin-react-redux react-redux redux
// How to use
// same path you provided in gatsby-config
// ./src/state/createStore.js
import { createStore } from 'redux';
function reducer() {
//...
}
// preloadedState will be passed in by the plugin
export default preloadedState => {
return createStore(reducer, preloadedState);
};