All skills
skilld-dev avatar

/pinia-colada-skilld

@b9c39cb

Data fetching layer for Vue built on Pinia. Use when writing, debugging, or reviewing code that imports @pinia/colada (pinia colada), including useQuery, useMutation, useInfiniteQuery, defineQuery, query cache invalidation, optimistic updates, plugins, SSR, or migrating from older versions. Provides current 1.4.x APIs, patterns, and migration rules.

Use this Skill: https://skilld.dev/gh/skilld-dev/vue-ecosystem-skills/pinia-colada-skilld

This session only. Nothing lands on disk.

referencesinfinite-queries.md

≈758 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Infinite queries

@pinia/colada 1.4.5 infinite query API. Types: dist/index.d.mts:928-1089.

Docs: https://pinia-colada.esm.dev/guide/infinite-queries.md

useInfiniteQuery merges pages into a single cache entry. Data shape is { pages: TData[], pageParams: TPageParam[] } (dist/index.d.mts:932-941). Use plain useQuery with the page in the key when you want each page as a separate entry (https://pinia-colada.esm.dev/guide/paginated-queries.md).

Basic usage

import { useInfiniteQuery } from '@pinia/colada'

const { data, hasNextPage, loadNextPage, asyncStatus } = useInfiniteQuery({
  key: () => ['feed', { search: search.value }],
  initialPageParam: 1,
  query: ({ pageParam, signal }) =>
    fetch(`/api/feed?page=${pageParam}`, { signal }).then(r => r.json()),
  getNextPageParam: (lastPage) => lastPage.nextPage ?? null,
})

Options beyond useQuery

Option Notes
initialPageParam required; value or function (dist/index.d.mts:961)
getNextPageParam required; (lastPage, allPages, lastPageParam, allPageParams). Return null/undefined to signal no more pages (dist/index.d.mts:973)
getPreviousPageParam optional; enables hasPreviousPage / loadPreviousPage (dist/index.d.mts:979)
maxPages keep only the N most recent pages; oldest pages are dropped (dist/index.d.mts:967)

Return values

Everything from useQuery plus hasNextPage, loadNextPage(options?), hasPreviousPage, loadPreviousPage(options?) (dist/index.d.mts:1006-1026). Load options: throwOnError (default false), cancelRefetch (default true).

Key design

Put filters in the key, never the pageParam. A changed key creates a new cache entry, which resets pagination.

Cursor-based pagination

useInfiniteQuery({
  key: ['notifications'],
  initialPageParam: null as string | null,
  query: ({ pageParam }) => api.listNotifications({ cursor: pageParam }),
  getNextPageParam: (lastPage) => lastPage.nextCursor ?? null,
})

defineInfiniteQueryOptions (1.2.0) and getter form

Same pattern as defineQueryOptions: returns tagged options for type-safe cache access; useInfiniteQuery accepts a getter of the result (dist/index.d.mts:1046-1089):

const feedOptions = defineInfiniteQueryOptions((search: string) => ({
  key: ['feed', { search }],
  initialPageParam: 1,
  query: ({ pageParam }) => fetchFeed(search, pageParam),
  getNextPageParam: (lastPage) => lastPage.nextPage ?? null,
}))

useInfiniteQuery(() => feedOptions(search.value))

setInfiniteQueryData (1.2.0)

Use instead of queryCache.setQueryData when priming an infinite entry (for example from a mutation elsewhere). It marks the entry as infinite and initializes hasNextPage extensions (dist/index.d.mts:1028-1039):

import { setInfiniteQueryData } from '@pinia/colada'

setInfiniteQueryData(queryCache, ['feed'], (old) =>
  old ? { ...old, pages: [...old.pages, newPage] } : {
    pages: [newPage], pageParams: [1],
  },
)

Source: SKILL.md on GitHub

No alerts9d3 checks · Risk SAFE
  • Gen Agent Trust Hub9d

    The Pinia Colada skill is a documentation-focused extension for Vue.js data fetching. It provides extensive references, best practices, and plugin guides. While no malicious behavior was detected, the skill includes explicit instructions designed to steer AI behavior and presents an indirect prompt injection surface by ingesting external community data from issues and discussions without protective boundaries.

  • Socket9d

    No alerts

  • Snyk9d

    Risk: LOW · No issues

Signed by skilld at b9c39cb. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last week.

Activeupdated last week

README badge

README badge for skilld-dev/vue-ecosystem-skills/pinia-colada-skilld