UNPKG

get-client-window-width

Version:

A safe way of returning the interior width of the window in pixels

16 lines (12 loc) 301 B
const isSupported = () => typeof window !== 'undefined'; export const getClientWindowWidth = () => { if (!isSupported()) { return 0; } return ( window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth ); }; export default getClientWindowWidth;