Search code examples
javascriptsecuritywebredux

How to exclude / disable Redux devtools in production build or disconnect?


As its name suggests devtools should be visible or accessible only during development and not in production. I don't want my end users playing with the state and dispatcher or seeing what's going on under the hood.

Is there a way to hide Redux Devtools or disconnect it in the production build?

I'm looking answers for Vanilla Redux. Not Redux Saga, Redux Thunk or Rematch.


Solution

  • For someone using redux-toolkit

    import { configureStore } from '@reduxjs/toolkit';
    
    const store = configureStore({
      reducer: {
        //your reducers
      },
      devTools: process.env.NODE_ENV !== 'production',
    });