/tanstack:meta-frameworkfrom tanstack
Integrating TanStack DB with meta-frameworks (TanStack Start, Next.js, Remix, Nuxt, SvelteKit). Client-side only: SSR is NOT supported — routes must disable SSR. Preloading eager collections in route loaders with collection.preload(). On-demand Query Collections require preloading the live query because source collection preload is a no-op. Multiple collection preloading with Promise.all. Framework-specific loader APIs.
Ships in tanstack. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
This skill builds on db-core. Read it first for collection setup and query builder.
TanStack DB collections are client-side only. SSR is not implemented. Routes using TanStack DB must disable SSR. The setup pattern is:
ssr: false on the routeuseLiveQuery in the component// start.tsx
import { createStart } from '@tanstack/react-start'
export const startInstance = createStart(() => {
return {
defaultSsr: false,
}
})
import { createFileRoute } from '@tanstack/react-router'
import { useLiveQuery } from '@tanstack/react-db'
export const Route = createFileRoute('/todos')({
ssr: false,
loader: async () => {
await todoCollection.preload()
return null
},
component: TodoPage,
})
function TodoPage() {
const { data: todos } = useLiveQuery({
query: (q) => q.from({ todo: todoCollection }),
})
return (
<ul>
{todos.map((t) => (
<li key={t.id}>{t.text}</li>
))}
</ul>
)
}
Calling preload() on an on-demand source collection is a no-op. Define the
live query once, preload it in the loader, and pass that same collection to the
framework hook:
import { createLiveQueryCollection, eq } from '@tanstack/db'
import { useLiveQuery } from '@tanstack/react-db'
const activeTodos = createLiveQueryCollection((q) =>
q
.from({ todo: todoCollection })
.where(({ todo }) => eq(todo.completed, false)),
)
export const Route = createFileRoute('/todos')({
ssr: false,
loader: async () => {
await activeTodos.preload()
return null
},
component: () => {
const { data } = useLiveQuery(activeTodos)
// ...
},
})
export const Route = createFileRoute('/electric')({
ssr: false,
loader: async () => {
await Promise.all([todoCollection.preload(), configCollection.preload()])
return null
},
component: ElectricPage,
})
// app/todos/page.tsx
'use client'
import { useEffect, useState } from 'react'
import { useLiveQuery } from '@tanstack/react-db'
export default function TodoPage() {
const { data: todos, isLoading } = useLiveQuery({
query: (q) => q.from({ todo: todoCollection }),
})
if (isLoading) return <div>Loading...</div>
return (
<ul>
{todos.map((t) => (
<li key={t.id}>{t.text}</li>
))}
</ul>
)
}
Next.js App Router components using TanStack DB must be client components ('use client'). There is no server-side preloading — collections sync on mount.
// app/todos/page.tsx
'use client'
import { useEffect } from 'react'
import { useLiveQuery } from '@tanstack/react-db'
// Trigger preload immediately when module is loaded
const preloadPromise = todoCollection.preload()
export default function TodoPage() {
const { data: todos } = useLiveQuery({
query: (q) => q.from({ todo: todoCollection }),
})
return (
<ul>
{todos.map((t) => (
<li key={t.id}>{t.text}</li>
))}
</ul>
)
}
// app/routes/todos.tsx
import { useLiveQuery } from '@tanstack/react-db'
import type { ClientLoaderFunctionArgs } from '@remix-run/react'
export const clientLoader = async ({ request }: ClientLoaderFunctionArgs) => {
await todoCollection.preload()
return null
}
// Prevent server loader from running
export const loader = () => null
export default function TodoPage() {
const { data: todos } = useLiveQuery({
query: (q) => q.from({ todo: todoCollection }),
})
return (
<ul>
{todos.map((t) => (
<li key={t.id}>{t.text}</li>
))}
</ul>
)
}
<!-- pages/todos.vue -->
<script setup lang="ts">
import { useLiveQuery } from '@tanstack/vue-db'
const { data: todos, isLoading } = useLiveQuery((q) =>
q.from({ todo: todoCollection }),
)
</script>
<template>
<ClientOnly>
<div v-if="isLoading">Loading...</div>
<ul v-else>
<li v-for="todo in todos" :key="todo.id">{{ todo.text }}</li>
</ul>
</ClientOnly>
</template>
Wrap TanStack DB components in <ClientOnly> to prevent SSR.
<!-- src/routes/todos/+page.svelte -->
<script lang="ts">
import { browser } from '$app/environment'
import { useLiveQuery } from '@tanstack/svelte-db'
const todosQuery = browser
? useLiveQuery((q) => q.from({ todo: todoCollection }))
: null
</script>
{#if todosQuery}
{#each todosQuery.data as todo (todo.id)}
<li>{todo.text}</li>
{/each}
{/if}
Or disable SSR for the route:
// src/routes/todos/+page.ts
export const ssr = false
For eager collections, collection.preload() starts the sync process and
returns a promise that resolves when the collection reaches "ready" status.
This means:
markReady() is called by the adapterSubsequent calls to preload() on an already-ready collection return immediately.
For on-demand collections, source collection.preload() warns and does
nothing because no subset has been requested. Create the required live query
and await liveQuery.preload().
For one global QueryClient and one global server resource, define the
collection in a shared module and import it in loaders and components:
// lib/collections.ts
import { createCollection, queryCollectionOptions } from '@tanstack/react-db'
export const todoCollection = createCollection(
queryCollectionOptions({ ... })
)
// routes/todos.tsx — loader uses the same collection instance
import { todoCollection } from '../lib/collections'
export const Route = createFileRoute('/todos')({
ssr: false,
loader: async () => {
await todoCollection.preload()
return null
},
component: () => {
const { data } = useLiveQuery({
query: (q) => q.from({ todo: todoCollection }),
})
// ...
},
})
When the QueryClient, tenant, project, account, or route parameter defines
the resource, create one stable collection per QueryClient and business
scope. Memoize it and put it in router/request context rather than using a
process-global collection. Remove unused entries and call
collection.cleanup() in long-lived scope maps.
See the Query adapter runtime and business-scope pattern.
This skill covers the client-side read path only (preloading, live queries). For server-side concerns:
createServerFn in TanStack Start, API routes in Next.js/Remix) — implement using your framework's server function pattern. See the Electric adapter reference for the txid handshake that mutations must return.Wrong:
export const Route = createFileRoute('/todos')({
loader: async () => {
await todoCollection.preload()
return null
},
})
Correct:
export const Route = createFileRoute('/todos')({
ssr: false,
loader: async () => {
await todoCollection.preload()
return null
},
})
TanStack DB collections are client-side only. Without ssr: false, the route loader runs on the server where collections cannot sync, causing hangs or errors.
Source: examples/react/todo/src/start.tsx
Wrong:
export const Route = createFileRoute('/todos')({
ssr: false,
component: TodoPage,
})
Correct:
export const Route = createFileRoute('/todos')({
ssr: false,
loader: async () => {
await todoCollection.preload()
return null
},
component: TodoPage,
})
Without preloading, the collection starts syncing when the component first renders, causing a loading flash. Preloading in the route loader starts sync during navigation, so the data is already there on that first render.
Wrong:
// routes/todos.tsx
const todoCollection = createCollection(queryCollectionOptions({ ... }))
export const Route = createFileRoute('/todos')({
ssr: false,
loader: async () => { await todoCollection.preload() },
component: () => {
const { data } = useLiveQuery({
query: (q) => q.from({ todo: todoCollection }),
})
},
})
Correct:
// lib/collections.ts — shared for a global QueryClient and global resource
export const todoCollection = createCollection(queryCollectionOptions({ ... }))
Collections are stable within a QueryClient and business scope; they are not
universal singletons. Creating several instances in one scope causes duplicate
syncs and split state. A request-, router-, tenant-, or route-scoped client
needs a scoped factory instead of the global module pattern.
See also: react-db/SKILL.md, vue-db/SKILL.md, svelte-db/SKILL.md, solid-db/SKILL.md, angular-db/SKILL.md — for framework-specific hook usage.
See also: db-core/collection-setup/SKILL.md — for collection creation and adapter selection.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub fcakiroglu16/marketplace --plugin tanstackOther plugins' skills for the same job
25 skills in this plugin
/auth-and-guardsRoute protection with beforeLoad, redirect()/throw redirect(), isRedirect helper, authenticated layout routes (_authenticated), non-redirect auth (inline login), RBAC with roles and permissions, auth provider integration (Auth0, Clerk, Supabase), router context for auth state./code-splittingAutomatic code splitting (autoCodeSplitting), .lazy.tsx convention, createLazyFileRoute, createLazyRoute, lazyRouteComponent, getRouteApi for typed hooks in split files, codeSplitGroupings per-route override, splitBehavior programmatic config, critical vs non-critical properties./coreUse TanStack Table v9 core architecture, stable data and columns, and inferred types. Route setup, missing APIs, row models, state, features, and framework-specific work.