15/121

Check if the code is running in the browser

We can detect if the current code is running in the browser by checking the existence of window and document objects:

const isBrowser = typeof window === 'object' && typeof document === 'object';

Might be useful