useScreenSize
Returns window width and height, updating on resize.
Returns window width and height, updating on resize.
During server rendering the initial values are 0 × 0; after mounting the hook reads the window size.
Usage
'use client';
import { useScreenSize } from '@prosazhin/pbcomponents';
function Example() {
const { width, height } = useScreenSize();
return (
<span>
{width} × {height}
</span>
);
}Hook API
Returns
| Value | Type / variants | Purpose |
|---|---|---|
width | number | Window width in pixels. |
height | number | Window height in pixels. |