We can detect if the current code is running in the browser by checking the existence of window and document objects:
window
document
const isBrowser = typeof window === 'object' && typeof document === 'object';