Search code examples
reactjsreact-reduxgoogle-chrome-devtools

How to disable redux devtool to hide state in browser after production?


I built and deployed a MERN web app.

How can I disable redux devtools to stop showing state to users? otherwise anyone with devtools chrome extension can view all the data in state. I do not want to remove it from dev mode, is there any way to hide all state just for production?

Source code: https://github.com/deepak-punia/complaint-management-software Deployed app: https://complaint-management-software.herokuapp.com/ redux state


Solution

  • You can you use a boolean value in createStore and use process.env.NODE_ENV to get the current environment to toggle it conditionally.

    Something like this

    const store = configureStore({
      reducer: {
        auth: authReduce,
        users: usersReduce,
      },
      devTools: process.env.NODE_ENV !== 'production',
    });
    
    export default store;