Files
agent-skills/skills/vueuse-functions/references/useMediaQuery.md
Jason Woltje f5792c40be feat: Complete fleet — 94 skills across 10+ domains
Pulled ALL skills from 15 source repositories:
- anthropics/skills: 16 (docs, design, MCP, testing)
- obra/superpowers: 14 (TDD, debugging, agents, planning)
- coreyhaines31/marketingskills: 25 (marketing, CRO, SEO, growth)
- better-auth/skills: 5 (auth patterns)
- vercel-labs/agent-skills: 5 (React, design, Vercel)
- antfu/skills: 16 (Vue, Vite, Vitest, pnpm, Turborepo)
- Plus 13 individual skills from various repos

Mosaic Stack is not limited to coding — the Orchestrator and
subagents serve coding, business, design, marketing, writing,
logistics, analysis, and more.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 16:27:42 -06:00

54 lines
1.5 KiB
Markdown

---
category: Browser
---
# useMediaQuery
Reactive [Media Query](https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Testing_media_queries). Once you've created a MediaQueryList object, you can check the result of the query or receive notifications when the result changes.
## Usage
```ts
import { useMediaQuery } from '@vueuse/core'
const isLargeScreen = useMediaQuery('(min-width: 1024px)')
const isPreferredDark = useMediaQuery('(prefers-color-scheme: dark)')
```
#### Server Side Rendering and Nuxt
If you are using `useMediaQuery` with SSR enabled, then you need to specify which screen size you would like to render on the server and before hydration to avoid an hydration mismatch
```ts
import { useMediaQuery } from '@vueuse/core'
const isLarge = useMediaQuery('(min-width: 1024px)', {
ssrWidth: 768 // Will enable SSR mode and render like if the screen was 768px wide
})
console.log(isLarge.value) // always false because ssrWidth of 768px is smaller than 1024px
onMounted(() => {
console.log(isLarge.value) // false if screen is smaller than 1024px, true if larger than 1024px
})
```
Alternatively you can set this up globally for your app using [`provideSSRWidth`](../useSSRWidth/index.md)
## Type Declarations
```ts
/**
* Reactive Media Query.
*
* @see https://vueuse.org/useMediaQuery
* @param query
* @param options
*/
export declare function useMediaQuery(
query: MaybeRefOrGetter<string>,
options?: ConfigurableWindow & {
ssrWidth?: number
},
): ComputedRef<boolean>
```