Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply VueUse composables in Vue 3/Nuxt projects to replace custom implementations with battle-tested utilities.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/useSSRWidth.md
1---2category: Browser3---45# useSSRWidth67Used to set a global viewport width which will be used when rendering SSR components that rely on the viewport width like [`useMediaQuery`](../useMediaQuery/index.md) or [`useBreakpoints`](../useBreakpoints/index.md)89## Usage1011```ts12import { provideSSRWidth } from '@vueuse/core'1314const app = createApp(App)1516provideSSRWidth(500, app)17```1819Or in the root component2021```vue22<script setup lang="ts">23import { provideSSRWidth } from '@vueuse/core'2425provideSSRWidth(500)26</script>27```2829To retrieve the provided value if you need it in a subcomponent3031```vue32<script setup lang="ts">33import { useSSRWidth } from '@vueuse/core'3435const width = useSSRWidth()36</script>37```3839## Type Declarations4041```ts42export declare function useSSRWidth(): number | undefined43export declare function provideSSRWidth(44width: number | null,45app?: App<unknown>,46): void47```48