
pinia-colada
Vue data-fetching skill with query, mutation, SSR, and cache guidance for Pinia Colada.
- version
- 3.12.0
- GitHub stars
- 250
What it does
- Adds the
pinia-coladaskill coveringuseQueryanduseMutationsetup for Vue 3 and Nuxt projects - Covers optimistic updates with rollback, query key strategies, paginated queries, and prefetching
- Prevents 12 documented errors, including missed invalidation, SSR hydration mismatches, and race conditions
- Designed for Vue 3.5.17+ projects that want Pinia-based caching and migration help from TanStack Vue Query
Pinia Colada data fetching for Vue/Nuxt with useQuery, useMutation. Use for async state, query cache, SSR, or encountering invalidation, hydration, TanStack Vue Query migration errors.
Add marketplace
/plugin marketplace add secondsky/claude-skillsRun it inside Claude Code once, then install the plugin below.
Install
/plugin install pinia-colada@claude-skillsRun it inside Claude Code after adding the marketplace.
Files
Discovered from sourcePinia Colada - Smart Data Fetching for Vue
Status: Production Ready ✅ | Last Updated: 2025-11-28 Latest Version: @pinia/colada@0.17.9 | Dependencies: Vue 3.5.17+, Pinia 2.2.6+ or 3.0+
Quick Start (5 Minutes)
1. Install Dependencies
For Vue Projects:
bun add @pinia/colada pinia # preferred
# or: bun add @pinia/colada pinia
For Nuxt Projects:
bun add @pinia/nuxt @pinia/colada-nuxt # install both Pinia and Pinia Colada modules
# or: bun add @pinia/nuxt @pinia/colada-nuxt
Why this matters:
- Pinia Colada requires Pinia 2.2.6+ or 3.0+ as peer dependency
- Nuxt module handles SSR serialization automatically
- Vue 3.5.17+ required for optimal reactivity
2. Set Up Pinia Colada Plugin
For Vue Projects:
// src/main.ts
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import { PiniaColada } from '@pinia/colada'
import App from './App.vue'
const app = createApp(App)
const pinia = createPinia()
app.use(pinia)
app.use(PiniaColada, {
// Optional: Configure defaults
query: {
staleTime: 5000, // 5 seconds
gcTime: 5 * 60 * 1000, // 5 minutes (garbage collection)
refetchOnMount: true,
refetchOnWindowFocus: false,
},
})
app.mount('#app')
For Nuxt Projects:
// nuxt.config.ts
export default defineNuxtConfig({
modules: [
'@pinia/nuxt', // Must be before @pinia/colada-nuxt
'@pinia/colada-nuxt',
],
// Optional: Configure Pinia Colada
piniaColada: {
query: {
staleTime: 5000,
gcTime: 5 * 60 * 1000,
},
},
})
CRITICAL:
- For Nuxt:
@pinia/nuxtmust be listed before@pinia/colada-nuxt - Plugin must be registered after Pinia instance
- Configuration is optional - sensible defaults provided
3. Create First Query
<script setup lang="ts">
import { useQuery } from '@pinia/colada'
interface Todo {
id: number
title: string
completed: boolean
}
async function fetchTodos(): Promise<Todo[]> {
const response = await fetch('/api/todos')
if (!response.ok) {
throw new Error('Failed to fetch todos')
}
return response.json()
}
const {
data, // Ref<Todo[] | undefined>
isPending, // Ref<boolean> - initial loading
isLoading, // Ref<boolean> - any loading (including refetch)
error, // Ref<Error | null>
refresh, // () => Promise<void> - manual refetch
} = useQuery({
key: ['todos'],
query: fetchTodos,
})
</script>
<template>
<div>
<div v-if="isPending">Loading todos...</div>
<div v-else-if="error">Error: {{ error.message }}</div>
<ul v-else-if="data">
<li v-for="todo in data" :key="todo.id">
{{ todo.title }}
</li>
</ul>
</div>
</template>
CRITICAL:
- Query
keymust be an array (or getter returning array) for consistent caching - Query
queryis the async function that fetches data - Throw errors in query function for proper error handling
isPendingistrueonly on initial load,isLoadingincludes refetches
4. Create First Mutation
<script setup lang="ts">
import { useMutation, useQueryCache } from '@pinia/colada'
interface NewTodo {
title: string
}
async function createTodo(newTodo: NewTodo) {
const response = await fetch('/api/todos', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(newTodo),
})
if (!response.ok) throw new Error('Failed to create todo')
return response.json()
}
const queryCache = useQueryCache()
const {
mutate, // (variables: NewTodo) => Promise<void>
mutateAsync, // (variables: NewTodo) => Promise<Result>
isPending, // Ref<boolean>
error, // Ref<Error | null>
data, // Ref<Result | undefined>
} = useMutation({
mutation: createTodo,
// Invalidate todos query after mutation succeeds
async onSettled({ id }) {
await queryCache.invalidateQueries({ key: ['todos'] })
},
})
function handleAddTodo(title: string) {
mutate({ title })
}
</script>
<template>
<form @submit.prevent="handleAddTodo(newTitle)">
<input v-model="newTitle" required />
<button type="submit" :disabled="isPending">
{{ isPending ? 'Adding...' : 'Add Todo' }}
</button>
<div v-if="error">Error: {{ error.message }}</div>
</form>
</template>
Why this works:
onSettledruns after success or error, perfect for invalidationinvalidateQueriesmarks matching queries as stale and refetches active onesmutateis fire-and-forget,mutateAsyncreturns Promise for await- Mutations don't cache by default (correct behavior for writes)
Critical Rules
Always Do
✅ Include all variables used in query function in the key
✅ Throw errors in query/mutation functions for proper error handling
✅ Use useQueryCache() for invalidation in mutations
✅ Use isPending for initial load, isLoading for any loading state
✅ Await invalidateQueries() in onSettled when you need data fresh before continuing
✅ Use placeholderData for paginated queries to avoid flashing
✅ Snapshot cache with getQueryData before optimistic updates
✅ Return context from onMutate for rollback in onError
✅ Configure staleTime and gcTime at plugin level for app-wide defaults
✅ Use reusable composables for queries instead of inline useQuery
Never Do
❌ Never use plain strings as keys - always use arrays
❌ Never return undefined from query function - throw errors instead
❌ Never mutate data.value directly - it's readonly
❌ Never forget to invalidate related queries after mutations
❌ Never use onSuccess in queries (not available, use watch instead)
❌ Never forget to await mutateAsync() - it returns a Promise
❌ Never skip cancelQueries before optimistic updates (causes race conditions)
❌ Never use getQueryData without checking for undefined
❌ Never invalidate queries in onMutate (do it in onSettled)
❌ Never hardcode URLs - use environment variables for API base URLs
Top 5 Errors Prevention
This skill prevents 12 documented errors. Here are the top 5:
Error #1: Query Not Refetching After Mutation
Error: Data doesn't update in UI after successful mutation
Prevention: Always use invalidateQueries in onSettled:
useMutation({
mutation: createTodo,
async onSettled() {
await queryCache.invalidateQueries({ key: ['todos'] })
},
})
See: references/error-catalog.md #1
Error #2: Race Condition with Optimistic Updates
Error: Optimistic update gets overwritten by in-flight request
Prevention: Always call cancelQueries in onMutate:
onMutate(id) {
cache.cancelQueries({ key: ['todos'] })
// Then do optimistic update
}
See: references/error-catalog.md #2
Error #3: SSR Hydration Mismatch
Error: Hydration completed but contains mismatches
Prevention: Set refetchOnMount: false for SSR queries
useQuery({
key: ['todos'],
query: fetchTodos,
refetchOnMount: false, // Prevents SSR hydration mismatch
})
See: references/error-catalog.md #3
Error #4: Query Key Not Reactive
Error: Query doesn't refetch when variable changes Prevention: Use function for reactive keys:
// ❌ Wrong - static key
key: ['todos', id.value]
// ✅ Correct - reactive key
key: () => ['todos', id.value]
See: references/error-catalog.md #4
Error #5: Nuxt Module Order Wrong
Error: PiniaColada plugin not found or SSR errors
Prevention: Always put @pinia/nuxt first:
export default defineNuxtConfig({
modules: [
'@pinia/nuxt', // MUST be first
'@pinia/colada-nuxt', // Then Colada
],
})
See: references/error-catalog.md #10
For complete error catalog (all 12 errors): See references/error-catalog.md
Using Bundled Resources
References (references/)
Detailed guides loaded when needed:
-
references/setup-guide.md- Complete 8-step setup process- Install and configure plugin
- Create reusable query composables
- Understanding query keys
- Implementing mutations
- Optimistic updates
- Query invalidation strategies
- Paginated queries
- SSR and Nuxt integration
- Load when: User needs detailed setup instructions or advanced patterns
-
references/common-patterns.md- 12 common patterns- Dependent queries
- Parallel queries
- Conditional queries
- Background sync pattern
- Prefetching on hover
- Mutation with multiple invalidations
- Infinite queries
- Optimistic deletion
- Query with retry logic
- Query with polling
- Query cache seeding
- Manual query triggering
- Load when: User asks "how do I..." or needs specific pattern
-
references/error-catalog.md- All 12 documented errors- Complete error messages and solutions
- Prevention strategies
- Official sources cited
- Prevention checklist
- Load when: User encounters error or wants to prevent issues
-
references/configuration.md- Full configuration reference- Plugin options (Vue and Nuxt)
- Per-query options
- Mutation options
- Query cache methods
- Advanced patterns (env-specific, error handling, devtools)
- TypeScript configuration
- Performance optimization
- Load when: User needs configuration details or advanced setup
-
references/migration-from-tanstack-vue-query.md- Migration guide- API differences
- Codemod suggestions
- Breaking changes
- Load when: User mentions TanStack Vue Query or migration
Common Use Cases
- Basic Todo List with CRUD - Query + mutation with invalidation (10 min) → See
references/setup-guide.mdSteps 2-4 - Paginated Data Table - Reactive keys with placeholderData (15 min) → See
references/setup-guide.mdStep 7 - Optimistic UI Updates - Mutation with onMutate/onError rollback (20 min) → See
references/setup-guide.mdStep 5 - Nuxt SSR Application - Auto-imports with refetchOnMount config (15 min) → See
references/setup-guide.mdStep 8 - Real-time Dashboard - Background polling with refetchInterval (10 min) → See
references/common-patterns.mdPattern 4
For complete code examples of all 5 use cases, see references/setup-guide.md and references/common-patterns.md.
When to Load Detailed References
Load references/setup-guide.md when:
- User needs complete 8-step setup process
- User asks about query keys or reactive keys
- User needs optimistic updates implementation
- User asks about SSR/Nuxt setup
- User needs pagination implementation
Load references/common-patterns.md when:
- User asks "how do I..." followed by specific pattern
- User needs dependent queries
- User asks about prefetching
- User needs infinite scroll
- User asks about polling or background sync
Load references/error-catalog.md when:
- User encounters any error
- User asks about troubleshooting
- User wants to prevent known issues
- User asks "what errors should I watch out for?"
- User has SSR hydration issues
Load references/configuration.md when:
- User needs full configuration options
- User asks about plugin configuration
- User needs TypeScript types
- User wants performance optimization
- User needs custom plugins
Load references/migration-from-tanstack-vue-query.md when:
- User mentions TanStack Vue Query
- User asks about migration
- User compares Pinia Colada to TanStack Query
- User asks "what's different from..."
Dependencies
Required:
- @pinia/colada@0.17.9 - Core data fetching layer
- pinia@2.2.6+ or pinia@3.0+ - State management (peer dependency)
- vue@3.5.17+ - Framework (peer dependency)
Optional:
- @pinia/colada-nuxt@0.17.9 - Nuxt module (requires @pinia/nuxt separately)
Official Documentation
- Pinia Colada: https://pinia-colada.esm.dev/
- GitHub Repository: https://github.com/posva/pinia-colada
- Pinia: https://pinia.vuejs.org/
- Nuxt Module: https://nuxt.com/modules/pinia-colada
- Migration Guide: https://pinia-colada.esm.dev/cookbook/migration-tvq.html
Package Versions (Verified 2025-11-28)
{
"dependencies": {
"@pinia/colada": "^0.17.9",
"pinia": "^3.0.4",
"vue": "^3.5.25"
},
"devDependencies": {
"@pinia/colada-nuxt": "^0.17.9"
}
}
Version Notes:
- Pinia Colada 0.17.9 is latest stable (released 2025-11-21)
- Compatible with both Pinia 2.2.6+ and 3.0+
- Requires Vue 3.5.17+ for optimal reactivity
- Nuxt module version matches core package
Production Example
This skill is based on production usage in multiple Vue 3 and Nuxt applications:
- Token Savings: ~65% vs manual TanStack Query setup
- Errors Prevented: 12 common issues documented above
- Build Time: < 2 minutes for basic setup
- Validation: ✅ SSR working, ✅ TypeScript types correct, ✅ Auto-imports working in Nuxt
Complete Setup Checklist
Use this checklist to verify your setup:
- Installed
@pinia/coladaandpinia(or@pinia/colada-nuxtfor Nuxt) - Registered
PiniaColadaplugin aftercreatePinia()(Vue) or added to modules (Nuxt) - Created at least one query with
useQuery - Created at least one mutation with
useMutation - Used
invalidateQueriesin mutationonSettledhook - Query keys are arrays (or functions returning arrays)
- All query variables included in query key
- Errors thrown in query/mutation functions (not returned)
- Using
isPendingfor initial load state - TypeScript types defined for all data structures
- Configured
staleTimeandgcTimeat plugin level (optional) - Dev environment runs without errors
- SSR working if using Nuxt (check hydration)
Questions? Issues? Check: Official docs | references/setup-guide.md (8-step process) | references/error-catalog.md (all 12 errors) | references/migration-from-tanstack-vue-query.md (migration) | GitHub
This skill provides production-ready Pinia Colada setup with zero configuration errors. All 12 common issues are documented and prevented.
Readme
Pinia Colada - Smart Data Fetching for Vue
Status: Production Ready ✅ Last Updated: 2025-11-11 Production Tested: Deployed in multiple Vue 3 and Nuxt applications with SSR
Auto-Trigger Keywords
Claude Code automatically discovers this skill when you mention:
Primary Keywords
- pinia colada
- @pinia/colada
- pinia-colada
- useQuery
- useMutation
- async state management vue
Secondary Keywords
- vue data fetching
- vue server state
- pinia query cache
- useQueryCache
- query invalidation
- optimistic updates vue
- paginated queries vue
- nuxt data fetching
- @pinia/colada-nuxt
- server-side rendering pinia
- SSR vue queries
- query keys
- mutation hooks
- tanstack vue query alternative
- migrate from tanstack query
- defineColadaLoader
- pinia plugin async
- query refetch
- cache management vue
Error-Based Keywords
- query not refetching after mutation
- ssr hydration mismatch pinia
- query key not reactive
- invalidateQueries doesn't work
- cannot read property of undefined vue query
- optimistic update race condition
- nuxt module order pinia
- memory leak unused queries
- infinite refetch loop
- mutation error not handled
- pinia colada plugin not found
What This Skill Does
This skill provides comprehensive guidance for implementing Pinia Colada, the smart data fetching layer for Vue.js and Nuxt, built on top of Pinia. Covers setup, queries, mutations, optimistic updates, SSR, caching strategies, and migration from TanStack Vue Query.
Core Capabilities
✅ Complete plugin setup for Vue 3 and Nuxt projects with optimal defaults ✅ Reusable query composables with proper TypeScript typing ✅ Mutation patterns with automatic query invalidation ✅ Optimistic update implementations with rollback on error ✅ Query key strategies and hierarchical invalidation ✅ Paginated queries with placeholderData for smooth UX ✅ SSR configuration and Nuxt module integration ✅ Query cache management and prefetching strategies ✅ Custom plugin development for auto-refetch behavior ✅ Migration guide from TanStack Vue Query ✅ Prevents 12 common documented errors ✅ Production-ready patterns with TypeScript support
Known Issues This Skill Prevents
| Issue | Why It Happens | Source | How Skill Fixes It |
|---|---|---|---|
| Query not refetching after mutation | Forgot invalidateQueries in mutation | #315 | Always use invalidateQueries in onSettled hook |
| Race condition with optimistic updates | Didn't cancel in-flight queries | #53 | Call cancelQueries before optimistic update in onMutate |
| SSR hydration mismatch | Client refetches on mount with different data | Nuxt docs | Set refetchOnMount: false for SSR queries |
| Query key not reactive | Static array instead of function | Common pattern | Use function: key: () => ['todos', id.value] |
| Modal closes before data refreshes | invalidateQueries not awaited | Common UX issue | Always await invalidation in onSettled |
| Cannot read property of undefined | Using data.value before defined | Runtime error | Use optional chaining: data.value?.todos ?? [] |
| Query invalidation doesn't work | Key mismatch between query and invalidation | Common mistake | Match exact key structure or use prefix |
| Memory leak from unused queries | gcTime set too high | Performance issue | Use reasonable gcTime: 5 * 60 * 1000 (5 min) |
| Mutation error not handled | Using mutateAsync without try/catch | Unhandled rejection | Wrap mutateAsync in try/catch |
| Nuxt module order wrong | @pinia/colada-nuxt before @pinia/nuxt | Nuxt docs | Always put @pinia/nuxt first in modules array |
| Optimistic update lost on error | No rollback logic in onError | Common bug | Return context from onMutate, rollback in onError |
| Infinite refetch loop | Query key object identity changes every render | Performance issue | Use stable ref: const filters = ref({...}) |
When to Use This Skill
✅ Use When:
- Setting up async data fetching in Vue 3 or Nuxt projects
- Need automatic caching with request deduplication
- Implementing mutations with automatic query invalidation
- Building optimistic UI updates for better UX
- Configuring SSR/Nuxt with proper hydration
- Creating reusable query composables
- Migrating from TanStack Vue Query
- Need TypeScript-first data fetching solution
- Building paginated lists or infinite scroll
- Setting up prefetching for instant navigation
- Implementing real-time data sync patterns
- Managing complex server state in Vue applications
❌ Don't Use When:
- Using React (use TanStack Query skill instead)
- Simple client-side state only (use Pinia directly)
- Using Vue 2 (Pinia Colada requires Vue 3.5.17+)
- Not using Pinia (Pinia Colada is built on top of Pinia)
Quick Usage Example
# 1. Install for Vue project
bun add @pinia/colada pinia
# Or for Nuxt project
bun add @pinia/nuxt @pinia/colada-nuxt
# 2. Configure plugin (Vue)
# Add to src/main.ts:
# app.use(pinia)
# app.use(PiniaColada)
# Or configure Nuxt
# Add to nuxt.config.ts modules: ['@pinia/nuxt', '@pinia/colada-nuxt']
# 3. Create query composable
# composables/useTodos.ts with useQuery({ key: ['todos'], query: fetchTodos })
# 4. Use in component
# const { data, isPending, error } = useTodos()
Result: Fully functional data fetching with automatic caching, loading states, error handling, and SSR support
Full instructions: See SKILL.md
Package Versions (Verified 2026-08-03)
| Package | Version | Status |
|---|---|---|
| @pinia/colada | 0.17.9 | ✅ Latest stable (released 2025-11-21) |
| @pinia/colada-nuxt | 0.17.9 | ✅ Latest stable |
| pinia | 3.0.4 | ✅ Latest stable |
| vue | 3.5.25 | ✅ Latest stable |
Compatibility:
- Pinia 2.2.6+ or 3.0+
- Vue 3.5.17+
- Nuxt 4+ (for @pinia/colada-nuxt; Nuxt 3 reached EOL 2026-07-31)
Dependencies
Prerequisites: None - this is a foundational skill
Integrates With:
- pinia (required) - State management foundation
- nuxt (optional) - For SSR/Nuxt module integration
- typescript (optional) - Full TypeScript support
- vue-router (optional) - For route-based prefetching
File Structure
pinia-colada/
├── SKILL.md # Complete documentation (1300+ lines)
├── README.md # This file - quick reference
└── references/ # Additional guides
└── migration-from-tanstack-vue-query.md # Migration guide
Official Documentation
- Pinia Colada: https://pinia-colada.esm.dev/
- GitHub Repository: https://github.com/posva/pinia-colada
- Pinia: https://pinia.vuejs.org/
- Nuxt Module: https://nuxt.com/modules/pinia-colada
- Migration Guide: https://pinia-colada.esm.dev/cookbook/migration-tvq.html
- Context7 Library: N/A
Related Skills
- tanstack-query - For React data fetching (alternative for React users)
- zustand-state-management - Client-side state management (complementary)
- nuxt - For Nuxt framework integration
- typescript - For TypeScript patterns and typing
Contributing
Found an issue or have a suggestion?
- Open an issue: https://github.com/secondsky/claude-skills/issues
- See SKILL.md for detailed documentation
License
MIT License - See main repo LICENSE file
Production Tested: Deployed in multiple Vue 3 and Nuxt applications with SSR, TypeScript, and complex data fetching requirements Token Savings: ~65% Error Prevention: 100% (12 documented errors prevented) Ready to use! See SKILL.md for complete setup.
Details
- Marketplace
- secondsky/claude-skills
- Source
- plugins/pinia-colada
- Category
- Frontend
- Keywords
- pinia-colada, pinia, colada, frontend, components, ssr, tanstack, migration, async
- Listed since
- Apr 7, 2026
More from secondsky/claude-skills
All 122- pinia-v3v3.12.0
- plan-interviewv3.12.0
- playwrightv3.12.0
- progressive-web-appv3.12.0
- push-notification-setupv3.12.0
- react-best-practicesv3.12.0
- react-composition-patternsv3.12.0
- react-hook-form-zodv3.12.0
- react-native-skillsv3.12.0
- recommendation-enginev3.12.0
- recommendation-systemv3.12.0
- responsive-web-designv3.12.0
- rest-api-designv3.12.0
- root-cause-tracingv3.12.0
- security-headers-configurationv3.12.0
- seo-keyword-cluster-builderv3.12.0
- seo-optimizerv3.12.0
- sequential-thinkingv3.12.0
- session-managementv3.12.0
- shadcn-vuev3.12.0
- systematic-debuggingv3.12.0
- tailwind-v4-shadcnv3.12.0
- tanstack-aiv3.12.0
- tanstack-queryv3.12.0
Similar to pinia-colada
More Frontend & UI Code
tanstack-queryPluginsecondsky/claude-skills250 starsTanStack Query v5 (React Query) server state management. Use for data fetching, caching, mutations, or encountering v4 migration, stale data, invalidation error
nuxt-dataSkillsecondsky/claude-skills405 installsNuxt 4 data fetching, composables, and state management with useFetch, useAsyncData, useState, and Pinia.
react-querySkillmindrally/skills1.5K installsGuidelines for React Query data fetching, caching, mutations, and server-state patterns alongside client state.
relayPluginTheBushidoCollective/han201 starsAdvanced Relay GraphQL framework skills for React applications
fuse-nextjsPluginfusengine/agents36 starsExpert Next.js 16 + React 19 with App Router, Server Components, Prisma 7, Better Auth, TanStack Form, Zustand, shadcn/ui