Installation
npx sse-hooks add use-media-query
yarn dlx sse-hooks add use-media-query
pnpm dlx sse-hooks add use-media-query
deno run -A npm:sse-hooks add use-media-query
bunx sse-hooks add use-media-query
Usage
import { useMediaQuery } from "./{hooks file}";
const isSmallScreen = useMediaQuery("(max-width: 600px)");
// Use `isSmallScreen` to conditionally apply styles or logic based on the screen size.
API
Parameters
| Prop | Default | Type |
|---|---|---|
options |
|
The options for customizing the behavior of the hook (optional).
|
query | - |
The media query to track. |
Returns
| Return Value | Default | Type |
|---|---|---|
return | - |
Hook return value |
Types Aliases
Changelog
useKey
A powerful sensor hook for handling keyboard shortcuts, sequences, and modifiers. It supports complex key combinations (`Ctrl+Shift+S`), Gmail-style sequences (`g then i`), and provides metadata for generating "Keyboard Shortcut" UI help modals.
useMediaSession
Custom hook that interacts with the Media Session API. It allows you to customize media notifications and handle media control events (like play, pause, next track) from the system's notification area or lock screen.