All Hooks
this project was heavily inspired by usehooks.dev and built with the purpose of increasing qwik ecosystem. by: @victorditadi

useMediaQuery

Subscribe and respond to media query changes with useMediaQuery.

INSTALL:
npm i @ditadi/qwik-hooks
DESCRIPTION:The useMediaQuery hook leverages the window.matchMedia API to subscribe to CSS media query changes, thereby providing real-time responsiveness to dynamic changes in the viewport or screen orientation. It allows the component to rerender whenever the media query’s result changes. It throws an error if attempted to be used on the server-side (media queries only work in the browser).
PARAMETERS
NameTypeDescription
querystringThe media query to listen changes
RETURN VALUEThe useMediaQuery hook returns an array with the following elements:
NameTypeDescription
sSignal<boolean>Returns a boolean value indicating whether the media query matches the current state of the device.
DEMO:

useMediaQuery

Resize your browser windows to see changes
Mobile
Medium
Large
Extra Large
Example: