Skip to main content

Documentation Index

Fetch the complete documentation index at: https://sunpeak.ai/docs/llms.txt

Use this file to discover all available pages before exploring further.

sunpeak API

Overview

The useIsMobile hook detects if the current viewport width is below the mobile breakpoint (768px).

Import

import { useIsMobile } from 'sunpeak';

Signature

function useIsMobile(): boolean

Returns

return
boolean
true if viewport width is less than 768px, false otherwise.

Usage

import { useIsMobile } from 'sunpeak';

function MyResource() {
  const isMobile = useIsMobile();

  return (
    <div className={isMobile ? 'mobile-layout' : 'desktop-layout'}>
      {isMobile ? 'Mobile view' : 'Desktop view'}
    </div>
  );
}