Determine if the current runtime is a browser in Node.js application
Here is how to determine in your Node.js scripts if the Runtime is in the browser or in the Node instance directly. This method is useful to have a different behavior depending on the environment, either in the browser or in the backend.
const isBrowser = () => ![typeof window, typeof document].includes('undefined');