useWindowSize
Layout/Viewport
A React hook that tracks browser window dimensions and updates on resize events, with SSR safety.
Installation
npm install @thibault.sh/hooks
API Reference
Signature
interface WindowSize {
width: number;
height: number;
}
function useWindowSize(): WindowSize
Returns
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. |