react check if localhost

JavaScript
if (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" || window.location.hostname === "") {
    alert("It's a local server!");
}
Source

Also in JavaScript: