useWindowSize
Layout/Viewport
A React hook that tracks browser window dimensions and updates on resize events, with SSR safety.
Installation
npm install @thibault.sh/hooksAPI Reference
Signature
interface WindowSize {
width: number;
height: number;
}
function useWindowSize(): WindowSizeReturns
WindowSize
An object containing the current window width and height.
Properties:
| Property | Type | Description |
|---|---|---|
width | number | Current window inner width in pixels. |
height | number | Current window inner height in pixels. |