UNPKG

@heroui/use-is-mobile

Version:

A hook that returns whether the device is mobile or not

14 lines (13 loc) 293 B
// src/index.ts import { useIsSSR } from "@react-aria/ssr"; var MOBILE_SCREEN_WIDTH = 700; function useIsMobile() { let isSSR = useIsSSR(); if (isSSR || typeof window === "undefined") { return false; } return window.screen.width <= MOBILE_SCREEN_WIDTH; } export { useIsMobile };