Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Vuejs Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-vuejs-knowledge-patch-nevaberry-plugins)
---
name: vuejs-knowledge-patch
description: Vue.js
version: "3.6.0-beta"
license: MIT
metadata:
author: Nevaberry
---
# Vue.js Knowledge Patch
Load this skill when upgrading or debugging Vue SFC compilation, reactivity,
rendering, hydration, Vue Router, Pinia, or Pinia Colada. Use the topic references
for detailed behavior, examples, and version attribution.
## Reference index
| Reference | Topics |
| --- | --- |
| [Vue Core and Release Channels](references/vue-core-and-vapor.md) | SFC compilation, types, reactivity, DOM bindings, SSR, hydration, Suspense, KeepAlive, Teleport, transitions |
| [Vue Router 5](references/vue-router-5.md) | Package migration, file-based routes, route types, experimental parameters and loaders, guards, scrolling |
| [Pinia 3 and 4](references/pinia-3.md) | Packaging, TypeScript, Devtools, injection, store refs, subscriptions, hydration, hot updates, Nuxt |
| [Pinia Colada Queries](references/pinia-colada-queries.md) | Query migration, defaults, keys, fetching, invalidation, pagination, hooks, metadata, types |
| [Pinia Colada Mutations and Integration](references/pinia-colada-mutations-and-integration.md) | Shared definitions, mutations, optimistic updates, Nuxt, SSR, Devtools, tests, plugins, persistence |
| [Vue Ecosystem Tooling](references/ecosystem-tooling.md) | Nuxt routing and data fetchers, Vite+ CLI and configuration, Void Cloud integration |
## Breaking changes and migration
### Pinia package requirements
Pinia 4 ships as ESM only. Install `@vue/devtools-api` v8 alongside it.
```sh
npm install pinia@4 @vue/devtools-api@8
```
Pinia 3.0 requires TypeScript 4.5 or later because its declarations use the
built-in `Awaited` utility type. Pinia 3 declares `"type": "module"` in
`package.json` and continues to ship CommonJS builds in `dist`.
### File-based routing migration
Vue Router 5 incorporates `unplugin-vue-router`. When upgrading a file-based
routing project, remove the standalone dependency and switch the Vite plugin
import to `vue-router/vite`.
```ts
import Vue from '@vitejs/plugin-vue'
import { defineConfig } from 'vite'
import VueRouter from 'vue-router/vite'
export default defineConfig({
plugins: [VueRouter(), Vue()],
})
```
Remove the `unplugin-vue-router/client` reference from `tsconfig.json` or
`env.d.ts` and keep the generated declaration file in the TypeScript project.
Set `VueRouter({ dts: 'src/routes.d.ts' })` if you want to place it under an
existing `src` include.
`vue-router/experimental` is now ESM-only. Load it with an ES module import.
With experimental routing, query parameters are optional by default. Code that
reads them must handle omitted values.
### Pinia Colada query overload migration
Pinia Colada 1.0 takes one getter for dynamic options. Replace
`useQuery(todoQuery, () => id.value)` with `useQuery(() => todoQuery(id.value))`,
and pass a getter for the key to `useQueryState(() => todoQuery(id.value).key)`.
To migrate call sites in `src`, run the supplied codemod.
```sh
pnpm --package=@ast-grep/cli dlx ast-grep scan -r node_modules/@pinia/colada/codemods/rules/migration-0-21-to-1-0.yaml -i src
```
### Destructured props in model options
Referencing a destructured `defineProps()` binding in the prop options of
`defineModel()`, such as its `default`, now triggers a compile error. Apply a
prop-dependent fallback when reading the model.
```vue
<script setup lang="ts">
const { initialTitle } = defineProps<{ initialTitle: string }>()
const title = defineModel<string>()
</script>
<template>{{ title ?? initialTitle }}</template>
```
## Vue core quick reference
Import `TemplateRef<T>` from `vue` to type template refs passed to helpers or
composables. TypeScript treats individual custom directive modifier keys as
optional; use `binding.modifiers.foo ?? false` for a definite boolean.
A root `render()` flushes the jobs it queued itself. Use `await nextTick()` when
subsequent code needs updates that were already queued elsewhere.
Reactive reads in a `watch()` callback are excluded from the enclosing effect's
dependencies. A watcher configured with `{ once: true }` stops after its callback
runs, including when the callback throws. If the current effect scope has already
stopped, `onScopeDispose()` runs the supplied cleanup immediately.
When a `<select multiple>` updates its `v-model`, Vue uses the current model type.
Switching from an array to a `Set` after mount makes the next selection emit a
`Set`; the reverse switch yields an array. With
`<select multiple v-model.number="selected">`, numeric option strings such as
`"42"` become numbers in the emitted `Set` when `selected` is a `Set`.
Unhandled errors from async `setup()` propagate to the server-rendering caller.
A caller awaiting `renderToString()` can handle the rejection.
## Experimental router loaders
Import `DataLoaderPlugin` from `vue-router/experimental` and pass it the router in
`{ router }`. Install it before `app.use(router)` so it can handle the initial
navigation.
```ts
import { createApp } from 'vue'
import { createRouter, createWebHistory } from 'vue-router'
import { routes } from 'vue-router/auto-routes'
import { DataLoaderPlugin } from 'vue-router/experimental'
import App from './App.vue'
const router = createRouter({ history: createWebHistory(), routes })
const app = createApp(App)
app.use(DataLoaderPlugin, { router })
app.use(router)
app.mount('#app')
```
Export the loader from the page's ordinary `<script>`, re-exporting it there if
it lives in a separate module. The router awaits the basic loader when navigating
to the page, including between different parameter values on the same page.
Components calling the composable share its state and can refetch with `reload()`
without navigating.
The experimental Pinia Colada loader uses its own entry point:
`import { defineColadaLoader } from 'vue-router/experimental/pinia-colada'`.
## Pinia Colada query quick reference
Install `PiniaColada` after Pinia and put app-wide query settings under
`queryOptions`. Queries are fresh for 5 seconds by default (`staleTime: 5_000`),
and inactive entries are eligible for garbage collection after 5 minutes
(`gcTime: 300_000`).
Use a getter, ref, or computed for the whole `key` and put resolved values inside
the serializable array. For example,
`key: () => ['todos', { page: page.value }]` tracks `page` and keeps each page in
its own cache entry.
`defineQueryOptions()` tags the key with the query result type for `getQueryData()`
and `setQueryData()`. For reactive inputs, define a function that returns concrete
options, then call it inside the getter passed to `useQuery()`. Spread its result
in that getter to override options at the call site.
`refresh()` reuses an in-flight request or fresh cached data. `refetch()` forces
a new fetch. Both resolve to `{ status, data, error }` by default, including on
failure. Pass `true` to either method to reject on failure. A failed refetch sets
the error while preserving the previous data.
Invalidation marks matching active and inactive entries stale, and by default
refetches only active entries. Pass `'all'` as the second argument to fetch
inactive matches too: `queryCache.invalidateQueries({ key: ['todos'] }, 'all')`.
A `useQuery()` inside a long-lived Pinia store keeps watching its key and can keep
refetching after the page unmounts. Gate automatic requests with a reactive option
such as `enabled: () => Boolean(route.params.id)`, or read existing data through
`useQueryCache()` when the store only needs cache access.
Use `placeholderData` to keep the previous page visible while a new key loads.
The composable reports `state.status === 'success'` for the placeholder and
`asyncStatus === 'loading'` during the request. The placeholder stays local to the
result, so the SSR payload serializes the underlying cache state.
## Mutation completion and optimistic updates
`mutate()` records failures in mutation state and runs the hooks. Use
`mutateAsync()` to await the result and catch failures at the call site. The value
returned by `onMutate` is available as context in
`onError(error, variables, context)` and
`onSettled(data, error, variables, context)`.
Return the promise from
`onSettled: () => queryCache.invalidateQueries({ key: ['todos'] })` to keep the
mutation loading until the refetch completes. App-wide mutation hooks go in
`mutationOptions`.
`queryCache.cancelQueries({ key })` cancels matching in-flight queries without
starting another fetch. When writing optimistic data, return the previous value
and the optimistic value from `onMutate`. Roll back only if
`queryCache.getQueryData(key) === optimisticValue` so a newer write survives.
Use `setQueryData()` with a replacement object or array because cached data is
held in shallow refs.
## Hydration and test integration
Pinia's `shouldHydrate()` honors `skipHydrate()` on non-plain objects such as
collection instances. A marked object keeps its client-side state during
hydration. Hydrating a reactive `Set` or `Map` replaces its contents with the
server state; entries present only in the client defaults are discarded.
Enabled Pinia Colada `useQuery()` calls participate in SSR automatically via
`onServerPrefetch`. For a client-only query, use
`enabled: typeof document !== 'undefined'`. The Nuxt module handles cache
serialization and hydration.
Mount component tests with `createPinia()` followed by `PiniaColada` so the cache
store actions execute. `createTestingPinia()` stubs those actions and breaks query
and mutation execution. Call `flushPromises()` after triggering asynchronous
query or mutation work.