naystack - v1.5.10
    Preparing search index...

    Function useBreakpoint

    • Returns whether a CSS media query currently matches. Useful for responsive behavior in JS.

      Returns null during SSR / before the first client-side check (to avoid hydration mismatches).

      Parameters

      • query: string

        A valid CSS media query string (e.g. "(min-width: 768px)", "(prefers-color-scheme: dark)").

      Returns boolean | null

      true if the query matches, false if it doesn't, or null during SSR.

      import { useBreakpoint } from "naystack/client";

      function ResponsiveNav() {
      const isMobile = useBreakpoint("(max-width: 639px)");
      if (isMobile === null) return <Skeleton />; // SSR fallback
      return isMobile ? <MobileNav /> : <DesktopNav />;
      }
      const prefersReducedMotion = useBreakpoint("(prefers-reduced-motion: reduce)");