Docs
useWindowSize

Track the dimensions of the browser window with useWindowSize.

Loading...

Installation

pnpm dlx shadcn@latest add https://usekit.kiron.dev/k/use-window-size

Usage

"use client"
 
import { useWindowSize } from "@/hooks/use-window-size"
 
const WindowSizeDisplay = () => {
  const { width, height } = useWindowSize()
 
  return (
    <div>
      <p>Window Width: {width}px</p>
      <p>Window Height: {height}px</p>
    </div>
  )
}

API Reference

Return Values

NameTypeDescription
widthnumberThe current width of the window, in pixels.
heightnumberThe current height of the window, in pixels.