Skip to content
Back to skills

Vuejs Knowledge Patch

ASecurity

Vue.js

  • 25 stars
  • 0 votes
  • 0 copies
  • 16 views
  • Added May 27, 2026
developmenttypescriptgoreactvuenodetestingapi

Works with

  • cli
  • api

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro scans all 5 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add Nevaberry/nevaberry-plugins --skill vuejs-knowledge-patch --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Vuejs Knowledge Patch?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Vuejs Knowledge Patch
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nevaberry-vuejs-knowledge-patch/badge)](https://www.skillsdirectory.com/skills/nevaberry-vuejs-knowledge-patch)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: vuejs-knowledge-patch
description: Vue.js
version: "3.6.0-beta"
license: MIT
metadata:
  author: Nevaberry
---


# Vue.js Knowledge Patch

Use this skill when changing Vue SFCs, rendering or hydration, Vue Router routes and data
loaders, Pinia stores, or Pinia Colada queries and mutations. Load the reference that matches
the task; the quick reference below starts with package and API migrations.

## Reference index

| Reference | Topics |
| --- | --- |
| [Vue Core and Release Channels](references/vue-core-and-vapor.md) | SFC compilation, types, reactivity, native bindings, SSR, hydration, Teleport, Suspense, and transitions |
| [Vue Router 5](references/vue-router-5.md) | Bundler integration, route declarations, editor types, parameter parsers, data loaders, navigation, and scrolling |
| [Pinia Package and Runtime](references/pinia-3.md) | Packaging, dependencies, injection, store refs, subscriptions, development, and hydration |
| [Pinia Colada Queries](references/pinia-colada-queries.md) | Query migration, defaults, keys, typed options, fetching, pagination, hooks, and errors |
| [Pinia Colada Mutations and Integration](references/pinia-colada-mutations-and-integration.md) | Shared state, mutations, optimistic updates, Nuxt, SSR, tests, and plugins |
| [Vue Ecosystem Tooling](references/ecosystem-tooling.md) | Nuxt integration, Vite+, and Void Cloud |

## Package and API migration

### ESM-only packaging and Devtools installation

Pinia 4 ships as ESM only. Install `@vue/devtools-api` v8 alongside it.

```sh
npm install pinia@4 @vue/devtools-api@8
```

### TypeScript 4.5 minimum

Pinia 3.0 requires TypeScript 4.5 or later because its declarations use the built-in
`Awaited` utility type.

### Built-in file-based routing

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()],
})
```

For Webpack, Rollup, or esbuild, use the corresponding adapter on the default export of
`vue-router/unplugin`, such as `VueRouter.webpack()`. Custom integrations import utilities
such as `createRoutesContext` and `resolveOptions` from that same entry point.

### Generated route declarations

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.

### ESM-only experimental entry point

`vue-router/experimental` is now ESM-only. Load it with an ES module import.

### Optional experimental query parameters

With experimental routing, query parameters are optional by default. Code that reads them
must handle omitted values.

### 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 `defineModel()` 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>
```

## Routing and data loaders

### Data-loader plugin setup

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')
```

### Page exports and basic loader behavior

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, and components calling the composable
share its state and can refetch with `reload()` without navigating.

### Pinia Colada loader import

The experimental Pinia Colada loader has its own entry point.

```ts
import { defineColadaLoader } from 'vue-router/experimental/pinia-colada'
```

## Query keys and fetching

### Global query defaults

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`). Install `PiniaColada`
after Pinia and put app-wide query settings under `queryOptions`, for example
`app.use(PiniaColada, { queryOptions: { staleTime: 30_000 } })`.

### Reactive query keys

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.

### Typed query options

`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.

### Manual fetching and errors

`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.

### Prefetching and seeding cache entries

Use `await queryCache.refresh(queryCache.ensure(todoQuery(id.value)))` to prefetch. When
seeding from data you already have, call `ensure(options)` before `setQueryData(options.key,
data)` so the entry has the query function and options for staleness and refetching.

### Refetching inactive queries

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, as in
`queryCache.invalidateQueries({ key: ['todos'] }, 'all')`.

## Mutations, server rendering, and tests

### Mutation hooks and completion

`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`.

### Optimistic cache updates and cancellation

`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.

### Server prefetch and custom hydration

Enabled `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. In a custom SSR setup, encode the result of
`serializeQueryCache(useQueryCache(pinia))` on the server, then call
`hydrateQueryCache(useQueryCache(pinia), revivedCache)` on the client after installing Pinia
and Pinia Colada.

### Component tests need real cache actions

Mount 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.

## Vue types and update timing

### Public `TemplateRef` type

Import `TemplateRef<T>` from `vue` to type template refs passed to helpers or composables.

```vue
<script setup lang="ts">
import { useTemplateRef, type TemplateRef } from 'vue'

const search: TemplateRef<HTMLInputElement> = useTemplateRef<HTMLInputElement>('search')
</script>

<template>
  <input ref="search" />
</template>
```

### Updates queued before a root render

A root `render()` flushes the jobs it queued itself. Use `await nextTick()` when subsequent
code needs updates that were already queued elsewhere.

Files in this skill

  • SKILL.md7.6 KB
  • references/data-loaders.md4.1 KB
  • references/pinia-colada.md6.1 KB
  • references/vapor-mode.md3.7 KB
  • references/vue-router-5.md4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.