Skip to Content
react-utilsuseWindowSize

useWindowSize

See source on Github 

Tracks window size which updates on window resize.

  • @param options - Configurable options
  • @param options.when - Whether window-size tracking is enabled.
  • @returns An object containing size information

Example

const { innerWidth, innerHeight } = useWindowSize() if (!innerWidth) return null return <div>{innerWidth} x {innerHeight}</div>