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/useRouteParams.md
1---2category: '@Router'3---45# useRouteParams67Shorthand for a reactive `route.params`.89## Usage1011```ts12import { useRouteParams } from '@vueuse/router'1314const userId = useRouteParams('userId')1516const userId = useRouteParams('userId', '-1') // or with a default value1718const userId = useRouteParams('page', '1', { transform: Number }) // or transforming value1920console.log(userId.value) // route.params.userId21userId.value = '100' // router.replace({ params: { userId: '100' } })22```2324## Type Declarations2526```ts27export declare function useRouteParams(28name: string,29): Ref<null | string | string[]>30export declare function useRouteParams<31T extends RouteParamValueRaw = RouteParamValueRaw,32K = T,33>(34name: string,35defaultValue?: MaybeRefOrGetter<T>,36options?: ReactiveRouteOptionsWithTransform<T, K>,37): Ref<K>38```39