Check if the code is running in the browser
JavaScript version
const isBrowser = typeof window === 'object' && typeof document === 'object';
TypeScript version
const isBrowser: boolean = typeof window === 'object' && typeof document === 'object';
JavaScript version
const isBrowser = typeof window === 'object' && typeof document === 'object';
TypeScript version
const isBrowser: boolean = typeof window === 'object' && typeof document === 'object';