Skip to main content
Version: Next



Window size hook for React.


npm install --save rooks

Importing the hook​

import {useWindowSize} from "rooks


function WindowComponent() {
const { innerWidth, innerHeight, outerHeight, outerWidth } = useWindowSize();

return (
<span>innerHeight - </span>
<span>innerWidth - </span>
<span>outerHeight - </span>
<span>outerWidth - </span>
render(<WindowComponent />);

Returned Object keys​

Returned object attributesTypeDescription
widthintinner width of window
heightintinner height of window
outerWidthintouter height of window
outerHeightintouter width of window

Codesandbox Example​

Basic usage​

Join Bhargav's discord server​

You can click on the floating discord icon at the bottom right of the screen and talk to us in our server.