Hooks

useMobile

A custom hook to determine if the user is on a mobile device

Example

import { useIsMobile } from '@vitnode/core/hooks/use-mobile';
import { useIsMobile } from '@vitnode/core/hooks/use-mobile';

export const ExampleComponent = () => {
  const isMobile = useIsMobile(); 

  return (
    <div>
      {isMobile ? (
        <p>You are using a mobile device.</p>
      ) : (
        <p>You are using a desktop device.</p>
      )}
    </div>
  );
};

On this page