use-mobile
a hook that returns true while the window is narrower than 768 px. the sidebar reads it to turn into a sheet on a phone.
bunx --bun shadcn@latest add @mk/use-mobileexample
- useIsMobile()
- false
- window
- not measured yet
resize the window across 768 px and the value flips.
- useIsMobile()
- false
- window
- not measured yet
resize the window across 768 px and the value flips.
upstream
base-nova’s hook, unchanged. the 768 px breakpoint is upstream’s; this site’s own layout changes at 900 and 600 px, in css. the hook returns false until the page hydrates, so markup rendered ahead of time always takes the desktop branch.