docs: add advanced skills for Vitest, Pinia, and Vue built-ins
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (8.3) (push) Has been cancelled
tests / ci (8.4) (push) Has been cancelled
tests / ci (8.5) (push) Has been cancelled

Add comprehensive reference documentation for:
- Vitest: environments, projects/workspaces, type testing, vi utilities
- Pinia: HMR, Nuxt integration, SSR setup
- Vue: built-in components (Transition, Teleport, Suspense, KeepAlive) and advanced directives
This commit is contained in:
Ovidiu U
2026-04-11 16:28:36 +01:00
parent 069a85cf11
commit 4a3ce4cc1d
405 changed files with 41122 additions and 0 deletions

View File

@@ -0,0 +1,79 @@
---
category: '@Router'
---
# useRouteQuery
Shorthand for a reactive `route.query`. Updates the URL query parameters when the ref changes.
## Usage
```ts
import { useRouteQuery } from '@vueuse/router'
const search = useRouteQuery('search')
const search = useRouteQuery('search', 'foo') // or with a default value
const page = useRouteQuery('page', '1', { transform: Number }) // or transforming value
console.log(search.value) // route.query.search
search.value = 'foobar' // router.replace({ query: { search: 'foobar' } })
```
### Navigation Mode
By default, changes use `router.replace()`. Set `mode: 'push'` to use `router.push()` instead.
```ts
import { useRouteQuery } from '@vueuse/router'
const search = useRouteQuery('search', '', { mode: 'push' })
```
### Bidirectional Transform
You can provide separate `get` and `set` transforms for reading and writing values.
```ts
import { useRouteQuery } from '@vueuse/router'
const filters = useRouteQuery('filters', [], {
transform: {
get: v => v ? v.split(',') : [],
set: v => v.join(','),
},
})
// Reading: 'a,b,c' -> ['a', 'b', 'c']
// Writing: ['a', 'b', 'c'] -> 'a,b,c'
```
### Default Value Behavior
When the value equals the default value, the query parameter is removed from the URL.
```ts
import { useRouteQuery } from '@vueuse/router'
const page = useRouteQuery('page', '1')
page.value = '2' // URL: ?page=2
page.value = '1' // URL: (no page param, since it equals default)
```
## Type Declarations
```ts
export declare function useRouteQuery(
name: string,
): Ref<undefined | null | string | string[]>
export declare function useRouteQuery<
T extends RouteQueryValueRaw = RouteQueryValueRaw,
K = T,
>(
name: string,
defaultValue?: MaybeRefOrGetter<T>,
options?: ReactiveRouteOptionsWithTransform<T, K>,
): Ref<K>
```