A React hook that detects whether the current viewport width is below a specified breakpoint
const MyComponent = () => { const isMobile = useIsMobile(768); return ( <div> {isMobile ? 'Mobile View' : 'Desktop View'} </div> );} Copy
const MyComponent = () => { const isMobile = useIsMobile(768); return ( <div> {isMobile ? 'Mobile View' : 'Desktop View'} </div> );}
The width threshold in pixels to determine mobile view (default: 768px)
boolean - True if the viewport width is less than the breakpoint
A React hook that detects whether the current viewport width is below a specified breakpoint
Example