Frontend & UISûr100100/100
Vue DB (TanStack)
Vue 3 bindings for TanStack DB. useLiveQuery composable with MaybeRefOrGetter query functions, ComputedRef return values for all fields (data, state, collection, status, isLoading, isReady, isError). Dependency arrays with Vue refs. Conditional queries via returning undefined/null. Pre-created collection support via ref or getter. Import from @tanstack/vue-db (re-exports all of @tanstack/db).
ou envoie-le directement à ton agent.
Installer dans ton projet
$ curl -fsSL https://arboristhree.xyz/cli/install-skill.mjs -o /tmp/arboris-install-skill.mjs && node /tmp/arboris-install-skill.mjs vue-db__tanstack-db__packages-vue-db-skills-f31547a70a50TanStack
TanStack/db
Contenu à copier
---
name: vue-db
description: >
Vue 3 bindings for TanStack DB. useLiveQuery composable with
MaybeRefOrGetter query functions, ComputedRef return values for all fields
(data, state, collection, status, isLoading, isReady, isError).
Dependency arrays with Vue refs. Conditional queries via returning
undefined/null. Pre-created collection support via ref or getter.
Import from @tanstack/vue-db (re-exports all of @tanstack/db).
type: framework
library: db
framework: vue
library_version: '0.6.17'
requires:
- db-core
sources:
- 'TanStack/db:docs/framework/vue/overview.md'
- 'TanStack/db:packages/vue-db/src/useLiveQuery.ts'
metadata:
origin: TanStack
---
This skill builds on db-core. Read it first for collection setup, query builder, and mutation patterns.
# TanStack DB — Vue
## Setup
```vue
<script setup lang="ts">
import { useLiveQuery, eq, not } from '@tanstack/vue-db'
const { data: todos, isLoading } = useLiveQuery((q) =>
q
.from({ todo: todoCollection })
.where(({ todo }) => not(todo.completed))
.orderBy(({ todo }) => todo.created_at, 'asc'),
)
</script>
<template>
<div v-if="isLoading">Loading...</div>
<ul v-else>
<li v-for="todo in todos" :key="todo.id">{{ todo.text }}</li>
</ul>
</template>
```
`@tanstack/vue-db` re-exports everything from `@tanstack/db`.
## Hook
### useLiveQuery
All return values are `ComputedRef`:
```ts
// Query function with reactive deps
const minPriority = ref(5)
const { data, isLoading, isReady, status } = useLiveQuery(
(q) =>
q
.from({ todo: todoCollection })
.where(({ todo }) => gt(todo.priority, minPriority.value)),
[minPriority],
)
// Config object
const { data } = useLiveQuery({
query: (q) => q.from({ todo: todoCollection }),
gcTime: 60000,
})
// Pre-created collection (reactive via ref)
const { data } = useLiveQuery(preloadedCollection)
// Conditional query
const userId = ref<number | null>(null)
const { data, status } = useLiveQuery(
(q) => {
if (!userId.value) return undefined
return q
.from({ todo: todoCollection })
.where(({ todo }) => eq(todo.userId, userId.value))
},
[userId],
)
```
## Vue-Specific Patterns
### Reactive dependencies with refs
```ts
const filter = ref('active')
const { data } = useLiveQuery(
(q) =>
q
.from({ todo: todoCollection })
.where(({ todo }) => eq(todo.status, filter.value)),
[filter],
)
// Query re-runs when filter.value changes
```
### Mutations in event handlers
```ts
const handleToggle = (id: number) => {
todoCollection.update(id, (draft) => {
draft.completed = !draft.completed
})
}
```
## Includes (Hierarchical Data)
When a query uses includes (subqueries in `select`), each child field is a live `Collection` by default. Subscribe to it with `useLiveQuery` in a subcomponent:
```vue
<!-- ProjectList.vue -->
<script setup lang="ts">
import { useLiveQuery, eq } from '@tanstack/vue-db'
const { data: projects } = useLiveQuery((q) =>
q.from({ p: projectsCollection }).select(({ p }) => ({
id: p.id,
name: p.name,
issues: q
.from({ i: issuesCollection })
.where(({ i }) => eq(i.projectId, p.id))
.select(({ i }) => ({ id: i.id, title: i.title })),
})),
)
</script>
<template>
<div v-for="project in projects" :key="project.id">
{{ project.name }}
<IssueList :issues-collection="project.issues" />
</div>
</template>
```
```vue
<!-- IssueList.vue — subscribes to the child Collection -->
<script setup lang="ts">
import { useLiveQuery } from '@tanstack/vue-db'
import type { Collection } from '@tanstack/db'
const props = defineProps<{ issuesCollection: Collection }>()
const { data: issues } = useLiveQuery(() => props.issuesCollection)
</script>
<template>
<ul>
<li v-for="issue in issues" :key="issue.id">{{ issue.title }}</li>
</ul>
</template>
```
With `toArray()`, child results are plain arrays and the parent re-emits on child changes:
```ts
import { toArray, eq } from '@tanstack/vue-db'
const { data: projects } = useLiveQuery((q) =>
q.from({ p: projectsCollection }).select(({ p }) => ({
id: p.id,
name: p.name,
issues: toArray(
q
.from({ i: issuesCollection })
.where(({ i }) => eq(i.projectId, p.id))
.select(({ i }) => ({ id: i.id, title: i.title })),
),
})),
)
// project.issues is a plain array — no subcomponent needed
```
See db-core/live-queries/SKILL.md for full includes rules (correlation conditions, nested includes, aggregates).
## Common Mistakes
### CRITICAL Missing reactive deps in dependency array
Wrong:
```ts
const userId = ref(1)
const { data } = useLiveQuery((q) =>
q
.from({ todo: todoCollection })
.where(({ todo }) => eq(todo.userId, userId.value)),
)
```
Correct:
```ts
const userId = ref(1)
const { data } = useLiveQuery(
(q) =>
q
.from({ todo: todoCollection })
.where(({ todo }) => eq(todo.userId, userId.value)),
[userId],
)
```
Reactive refs used in the query must be included in the deps array for the query to re-run on changes.
Source: docs/framework/vue/overview.md
See also: db-core/live-queries/SKILL.md — for query builder API.
See also: db-core/mutations-optimistic/SKILL.md — for mutation patterns.Colle ce Markdown dans ton agent ou utilise les boutons ci-dessus pour l’écrire dans ton projet.
Ce que fait Vue DB (TanStack)
Applique les pratiques du skill vue-db__tanstack-db__packages-vue-db-skills-f31547a70a50.
Comment utiliser Vue DB (TanStack)
1
Copie le prompt
Un clic copie le prompt packagé (ou l'envoie à ton agent).
2
L'agent installe le skill
Il ajoute le SKILL.md et ses ressources à ton projet.
3
Activation automatique
Le skill s'active dès que le contexte correspond.
Déclencheurs pour Vue DB (TanStack)
Dis simplement à ton agent quelque chose comme :
Applique le skill vue-db__tanstack-db__packages-vue-db-skills-f31547a70a50 à cette tâche
Utilise vue-db__tanstack-db__packages-vue-db-skills-f31547a70a50 pour améliorer cette implémentation
Passe en revue ce sujet avec vue-db__tanstack-db__packages-vue-db-skills-f31547a70a50
Skills liés à Vue DB (TanStack)
accessibility
Design, implement, and audit accessible UI to WCAG 2.2 Level AA across Web, iOS, and Android — semantic ARIA roles and labels, accessibility traits and hints, focus management, contrast, target size, and screen-reader support. Use when building or auditing UI for accessibility compliance, keyboard navigation, or screen-reader support.Accessibility Pass (Microsoft)
Use this skill whenever the user asks to check, review, or fix the accessibility of a PowerPoint deck, Word document, HTML page, or Markdown file, and before handing over any deck or document this agent just generated, so it does not ship with missing alt text, untitled slides, or unreadable colour contrast.Add Connector (Microsoft)
Use when adding a Power Platform connector to an Expo/React Native Power Apps mobile app and no dedicated mobile connector skill exists.