Skip to content
PluginStats

@tanstack/ai-persistence weekly downloads statistics

By tanstack (53 listings) · npm · AI SDKs

Composable state persistence for TanStack AI messages, runs, interrupts, metadata, and locks.

View on npm Fresh · Dec 6, 2026

@tanstack/ai-persistence has 323,607 recorded weekly downloads on npm, an increase of 55.0% over the past 30 days, ranking #453 of 3,247 tracked listings.

Weekly downloads
323,607
Official API · Dec 5, 2026
7-day growth
+5.9%
+18.1K weekly downloads
30-day growth
+55.0%
+114.8K weekly downloads
90-day growth
+1856%
+307.1K weekly downloads
Rank
#453
▼ 6 in 7 days

About @tanstack/ai-persistence

<div align="center"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://tanstack.com/api/readme/ai.png?theme=dark" /> <source media="(prefers-color-scheme: light)" srcset="https://tanstack.com/api/readme/ai.png" /> <img src="https://tanstack.com/api/readme/ai.png" alt="TanStack AI" width="900" /> </picture> </div> <br />

@tanstack/ai-persistence

Composable state persistence for TanStack AI messages, runs, interrupts, metadata, and locks

A conversation that only lives in memory is gone on reload and absent on a second device. This package stores it in your own database: one middleware on the server writes the transcript — and, with the matching stores configured, run status and pending approvals — through an adapter you define, and the client asks the server for the thread on mount. The client half ships in the framework package you already use (@tanstack/ai-react, -vue, -solid, -svelte, -angular, or @tanstack/ai-client).

Installation

npm install @tanstack/ai-persistence
# or
pnpm add @tanstack/ai-persistence
# or
yarn add @tanstack/ai-persistence

Usage

Server: store the conversation

withPersistence writes the transcript into your messages store, plus run status and pending approvals when the adapter also provides runs and interrupts. Start with memoryPersistence() for local development and swap in your own adapter later:

import {
  chat,
  chatParamsFromRequest,
  toServerSentEventsResponse,
} from '@tanstack/ai'
import { openaiText } from '@tanstack/ai-openai'
import { withPersistence } from '@tanstack/ai-persistence'
import { persistence } from './persistence'

export async function POST(request: Request) {
  const params = await chatParamsFromRequest(request)
  const stream = chat({
    adapter: openaiText('gpt-5.5'),
    messages: params.messages,
    threadId: params.threadId,
    runId: params.runId,
    ...(params.resume ? { resume: params.resume } : {}),
    middleware: [withPersistence(persistence)],
  })
  return toServerSentEventsResponse(stream)
}
Client: bring it back

persistence: true puts the server in charge: the browser caches nothing and fetches the thread on mount. Best for multi-user and multi-device apps.

import { fetchServerSentEvents, useChat } from '@tanstack/ai-react'

function Chat() {
  const { messages, sendMessage } = useChat({
    threadId: 'support-chat',
    connection: fetchServerSentEvents('/api/chat'),
    persistence: true,
  })
  return <button onClick={() => sendMessage('hi')}>{messages.length}</button>
}

Prefer the browser to own the history? Pass a storage adapter instead — localStoragePersistence(), sessionStoragePersistence(), or indexedDBPersistence() — and no server store is needed.

Survive a reload mid-answer

Add a GET on the same route. reconstructChat returns the stored thread plus a cursor to any run still generating; useChat tails that run so the reply finishes in place.

import { chatParamsFromRequest } from '@tanstack/ai'
import { reconstructChat } from '@tanstack/ai-persistence'
import { persistence } from './persistence'

declare function ownsThread(
  request: Request,
  threadId: string,
): Promise<boolean>

export function GET(request: Request) {
  return reconstructChat(persistence, request, {
    // WITHOUT this, anyone who guesses a thread id gets the whole transcript.
    authorize: async (threadId, req) => ownsThread(req, threadId),
  })
}

Build your own adapter

An adapter is a plain object of store functions. The core never looks at your tables, so the schema stays yours. One store, messages, is enough for withPersistence:

import {
  defineAIPersistence,
  defineMessageStore,
} from '@tanstack/ai-persistence'
import { db } from './db'

export const persistence = defineAIPersistence({
  stores: {
    messages: defineMessageStore({
      // Return [] for a thread that was never saved, never null.
      loadThread: (threadId) => db.threads.messages(threadId),
      // The full transcript, not a delta. Overwrite what you had.
      saveThread: (threadId, messages) => db.threads.save(threadId, messages),
    }),
  },
})

The other stores are optional and add capabilities as you provide them: runs, interrupts, and metadata for chat state; generationRuns, artifacts, and blobs for image, video, speech, and transcription runs. composePersistence layers overrides on top of a base backend.

Prove it with the conformance suite

The same suite every packaged backend runs is shipped for yours:

import { runPersistenceConformance } from '@tanstack/ai-persistence/testkit'
import { sqlitePersistence } from './sqlite-persistence'

runPersistenceConformance('my sqlite adapter', () =>
  sqlitePersistence({ url: ':memory:', migrate: true }),
)

Stores you do not provide go in skip. The testkit is a Vitest suite; vitest is an optional peer dependency, so install it in your project before importing @tanstack/ai-persistence/testkit.

Documentation

License

MIT

Description from the npm listing.

  • ai
  • ai-sdk
  • typescript
  • tanstack
  • tanstack-intent
  • persistence
  • durable
  • resume
  • chat-history

README badge

Show your rank in a README or on your website. The badge updates automatically.

Charts

Images: 30d · 1y · all time · 1600×900 dark

Adoption over time

@tanstack/ai-persistence weekly downloads on npm, last 90 days: 323,607 weekly downloads as of Dec 5, 2026, +1856% over 90 days.@tanstack/ai-persistenceWeekly downloads on npm · Last 90 days323,607downloads / week+1856% over 90 days050K100K150K200K250K300K350KSep 6Sep 21Oct 6Oct 21Nov 5Nov 20Dec 5downloads / weekobservedarchived (Internet Archive)no observationsSep 7, 2026 – Dec 5, 2026 · 90 observations · Updated Dec …pluginstats.com
@tanstack/ai-persistence weekly downloads on npm, last 90 days: 323,607 weekly downloads as of Dec 5, 2026, +1856% over 90 days.

7/30/90-day growth

@tanstack/ai-persistence weekly downloads growth on npm: +5.9% over 7 days, +55.0% over 30 days, +1856% over 90 days.@tanstack/ai-persistenceWeekly downloads growth on npm323,607downloads / week now7-day growth+18,095 weekly downloads+5.9%30-day growth+114,842 weekly downloads+55.0%90-day growth+307,065 weekly downloads+1856%Growth vs. nearest observation to each baseline date · Updated Dec 5, 2026pluginstats.com
@tanstack/ai-persistence weekly downloads growth on npm: +5.9% over 7 days, +55.0% over 30 days, +1856% over 90 days.

Ranking history

@tanstack/ai-persistence npm ranking history: currently #453 (by weekly downloads).@tanstack/ai-persistencenpm ranking · by weekly downloads · Last 90 days#453current rank#420#440#460#480#500#520#540#560#580Sep 7Sep 22Oct 7Oct 22Nov 6Nov 21Dec 6rankOct 18, 2026 – Dec 6, 2026 · 44 observations · Updated Dec 5, 2026pluginstats.com
@tanstack/ai-persistence npm ranking history: currently #453 (by weekly downloads).

Listing placement

All npm3,247 listings · 163 pages · 1,084 shown · page 23, #13 (overall #453)
All npm: every listing in weekly downloads order

Listing placement

AI SDKs378 listings · 19 pages · page 2, #4 (overall #24)
AI SDKs: every listing in weekly downloads order

Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.

Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.

Recent observations

Full history (170)
Recent weekly downloads observations for @tanstack/ai-persistence
Date (UTC)Weekly downloadsChange vs. previous
323,607-7.9K
331,528-3.4K
334,944-5.8K
340,770+17.8K
322,932+15.9K
307,050-3.9K
310,973+5.5K
305,512+10.4K
295,151+5.4K
289,745+17.8K
271,957+3.4K
268,510+22.5K
246,019+822
245,197—

Data source

Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.

Listing: https://www.npmjs.com/package/@tanstack/ai-persistence. First seen Oct 16, 2026; last successful collection Dec 6, 2026. See the methodology.