Packages

@pinia/colada

1.4.9 · 30 Oct 2026MIT207.8k / weekRepositoryHomepagenpmAtom feed

Your version

0.20.0

23 Dec 2025Where it was published

0.21.7 is the newest release of 0.20.x.

In short

8 breaking7 new4 fixed

  • Breaking

    Remove devtools from production builds

  • Breaking

    The merge option has been removed and data contains an object with pages and pageParams arrays that can be flattened.

  • Breaking

    initialPage has now been replaced with initialPageParam

  • Breaking

    loadMore has been renamed loadNextPage

  • Breaking

    getNextPageParam is now a required option

  • Breaking

    Invalidating now works just as with regular queries, which means that you probably want to set stale value higher (or disable it) to avoid refetching multiple pages when an infinite query is invalidated. Also, you might want to set refetchOn* options to false.

  • Breaking

    It's now possible to have bi-directional navigation

  • Breaking

    There is now hasNextPage and hasPreviousPage

Release note

Breaking Changes

  • Breaking

    Remove devtools from production builds

This release completely changed how useInfiniteQuery() works, the parameters and returned values:

  • Breaking

    The merge option has been removed and data contains an object with pages and pageParams arrays that can be flattened.

  • Breaking

    initialPage has now been replaced with initialPageParam

  • Breaking

    loadMore has been renamed loadNextPage

  • Breaking

    getNextPageParam is now a required option

  • Breaking

    Invalidating now works just as with regular queries, which means that you probably want to set stale value higher (or disable it) to avoid refetching multiple pages when an infinite query is invalidated. Also, you might want to set refetchOn* options to false.

  • Breaking

    It's now possible to have bi-directional navigation

  • Breaking

    There is now hasNextPage and hasPreviousPage

Any feedback on the feature and improvements is welcome!

Here is a complete example of what it looks in action:

<script setup lang="ts">
import { useInfiniteQuery } from '@pinia/colada'
import { onWatcherCleanup, useTemplateRef, watch } from 'vue'

const {
  state: factsPages,
  loadNextPage,
  asyncStatus,
  isDelaying,
  hasNextPage,
} = useInfiniteQuery({
  key: ['feed'],
  query: async ({ pageParam }) => factsApi.get<CatFacts>({ query: { page: pageParam, limit: 10 } }),
  initialPageParam: 1,
  getNextPageParam(lastPage) {
    return lastPage.next_page_url
  }
  // plugins
  retry: 0,
  delay: 0,
})

// we only need an array
const facts = computed(() => factPages.value.data?.pages.flat())
const loadMoreEl = useTemplateRef('load-more')

watch(loadMoreEl, (el) => {
  if (el) {
    const observer = new IntersectionObserver(
      (entries) => {
        if (entries[0]?.isIntersecting) {
          loadNextPage()
        }
      },
      {
        rootMargin: '300px',
        threshold: [0],
      },
    )
    observer.observe(el)
    onWatcherCleanup(() => {
      observer.disconnect()
    })
  }
})
</script>

<template>
  <div>
    <button :disabled="asyncStatus === 'loading' || isDelaying" @click="loadMore()">
      Load more (or scroll down)
    </button>
    <template v-if="facts?.length">
      <p>We have loaded {{ facts.length }} facts</p>
      <details>
        <summary>Show raw</summary>
        <pre>{{ facts }}</pre>
      </details>

      <blockquote v-for="fact in facts">
        {{ fact }}
      </blockquote>

      <p v-if="hasNextPage" ref="load-more">Loading more...</p>
    </template>
  </div>
</template>

Features

  • Json-viewer for data, options, vars

  • Wip

  • Wip

  • Wip infinite query

  • NextPage works

  • ThrowOnError in infiniteQuery

  • infinite: Add cancelRefetch

  • infinite: MaxPages

Bug Fixes

  • Use own local storage key

  • Update mutations more often

  • Higher z-index for button

  • infinite: Invalidation should refetch

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.