How to disable React Developer Tools


React Developer Tools can be opened with any React app.

This makes sense for development, but what about production? I ask this because any user can technically use devtools to poke around your app.

Luckily, there’s a way to disable it. All you need to do is override the devtools global hook before React is loaded:

<!-- index.html -->
<script>
    // before React is loaded
    if (typeof window.__REACT_DEVTOOLS_GLOBAL_HOOK__ === 'object') {
        __REACT_DEVTOOLS_GLOBAL_HOOK__.inject = function() {};
    }
</script>

You can find more information by checking out the issue.



Please support this site and join our Discord!