Skip to content
Source
Sign inSign up
TanStack/db
Open History to see the last commit

domain_map.yaml

710 lines38.4 KB

1# domain_map.yaml
2# Generated by skill-domain-discovery
3# Library: @tanstack/db
4# Version: 0.5.30
5# Date: 2026-03-04
6# Status: reviewed
7​
8library:
9 name: '@tanstack/db'
10 version: '0.5.30'
11 repository: 'https://github.com/TanStack/db'
12 description: 'Reactive client store with normalized collections, sub-millisecond live queries, and instant optimistic mutations'
13 primary_framework: 'framework-agnostic (React, Vue, Svelte, Solid, Angular adapters)'
14​
15domains:
16 - name: 'Collection Setup & Schema'
17 slug: 'collection-setup'
18 description: 'Creating and configuring typed collections from any data source, with optional schema validation, type transformations, and adapter-specific sync patterns'
19​
20 - name: 'Live Query Construction'
21 slug: 'live-queries'
22 description: 'Building SQL-like reactive queries across collections using the fluent query builder API with expressions, joins, aggregations, and derived collections'
23​
24 - name: 'Framework Integration'
25 slug: 'framework-integration'
26 description: 'Binding live queries to UI framework components using framework-specific hooks, dependency tracking, Suspense, and pagination'
27​
28 - name: 'Mutations & Optimistic State'
29 slug: 'mutations-optimistic'
30 description: 'Writing data to collections with instant optimistic feedback, managing transaction lifecycles, and handling rollback on failure'
31​
32 - name: 'Meta-Framework Integration'
33 slug: 'meta-framework'
34 description: 'Client-side preloading of collections in route loaders for TanStack Start/Router, Next.js, Remix, Nuxt, and SvelteKit — ensuring data is ready before component render'
35​
36 - name: 'Custom Adapter Authoring'
37 slug: 'custom-adapter'
38 description: 'Building custom collection adapters that implement the SyncConfig contract for new backends'
39​
40 - name: 'Offline Transactions'
41 slug: 'offline'
42 description: 'Offline-first transaction queueing with persistence, retry, multi-tab coordination, and connectivity detection'
43​
44skills:
45 - name: 'Collection Setup'
46 slug: 'collection-setup'
47 domain: 'collection-setup'
48 description: 'Creating and configuring typed collections backed by any data source'
49 type: 'core'
50 covers:
51 - 'createCollection'
52 - 'queryCollectionOptions (@tanstack/query-db-collection)'
53 - 'electricCollectionOptions (@tanstack/electric-db-collection)'
54 - 'trailbaseCollectionOptions (@tanstack/trailbase-db-collection)'
55 - 'powerSyncCollectionOptions (@tanstack/powersync-db-collection)'
56 - 'rxdbCollectionOptions (@tanstack/rxdb-db-collection)'
57 - 'localOnlyCollectionOptions'
58 - 'localStorageCollectionOptions'
59 - 'CollectionConfig interface (id, getKey, schema, sync, compare, autoIndex, startSync, gcTime, utils)'
60 - 'StandardSchema integration (Zod, Valibot, ArkType, Effect)'
61 - 'Schema validation (TInput vs TOutput, transformations, defaults)'
62 - 'Collection lifecycle (idle -> loading -> initialCommit -> ready -> error -> cleaned-up)'
63 - 'Collection status tracking (isReady, isLoading, isError, isCleanedUp)'
64 - 'localOnly -> real backend upgrade path'
65 - 'Adapter-specific sync patterns (Electric txid, Query direct writes, PowerSync persistence)'
66 - 'Sync modes (eager, on-demand, progressive)'
67 tasks:
68 - 'Create a collection backed by TanStack Query for REST API data'
69 - 'Create a collection synced with ElectricSQL for real-time Postgres data'
70 - 'Create a local-only collection for temporary UI state'
71 - 'Add schema validation with type transformations (e.g. string -> Date)'
72 - 'Configure collection with custom getKey, gcTime, and autoIndex'
73 - 'Create a localStorage collection for cross-tab persistent state'
74 - 'Configure PowerSync collection with custom serializer'
75 - 'Prototype with localOnlyCollectionOptions then swap to a real backend'
76 - 'Configure on-demand sync mode for large datasets'
77 - 'Track Electric txid to prevent optimistic state flash'
78 - 'Use direct writes to update query collection without refetch'
79 subsystems:
80 - name: 'TanStack Query adapter'
81 package: '@tanstack/query-db-collection'
82 config_surface: 'queryKey, queryFn, queryClient, select, enabled, refetchInterval, staleTime, syncMode'
83 - name: 'ElectricSQL adapter'
84 package: '@tanstack/electric-db-collection'
85 config_surface: 'shapeOptions, syncMode (eager/on-demand/progressive), txid tracking via awaitTxId/awaitMatch'
86 - name: 'PowerSync adapter'
87 package: '@tanstack/powersync-db-collection'
88 config_surface: 'database, table, conversions, batchSize, syncMode'
89 - name: 'RxDB adapter'
90 package: '@tanstack/rxdb-db-collection'
91 config_surface: 'rxCollection, syncBatchSize; keys always strings'
92 - name: 'TrailBase adapter'
93 package: '@tanstack/trailbase-db-collection'
94 config_surface: 'recordApi, conversions'
95 - name: 'Local-only'
96 package: '@tanstack/db'
97 config_surface: 'getKey, schema, initialData'
98 - name: 'localStorage'
99 package: '@tanstack/db'
100 config_surface: 'storageKey, getKey, schema'
101 failure_modes:
102 - mistake: 'queryFn returning empty array deletes all collection data'
103 mechanism: "queryCollectionOptions treats queryFn result as complete server state; returning [] means 'server has no items', causing all existing items to be deleted from the collection"
104 wrong_pattern: |
105 queryFn: async () => {
106 const res = await fetch('/api/todos?status=active')
107 return res.json() // returns [] when no active todos
108 }
109 correct_pattern: |
110 queryFn: async () => {
111 const res = await fetch('/api/todos') // fetch ALL todos
112 return res.json()
113 }
114 // Or use on-demand sync mode for filtered queries
115 source: 'docs/collections/query-collection.md - Full State Sync section'
116 priority: 'CRITICAL'
117 skills: ['collection-setup']
118​
119 - mistake: 'Not knowing which collection type to use for a given backend'
120 mechanism: 'AI agents default to bare createCollection or localOnlyCollectionOptions when they should use queryCollectionOptions, electricCollectionOptions, etc.; each adapter handles sync, handlers, and utilities differently'
121 source: 'maintainer interview'
122 priority: 'CRITICAL'
123 skills: ['collection-setup']
124​
125 - mistake: 'Using async schema validation'
126 mechanism: 'Schema validation must be synchronous; returning a Promise from a schema throws SchemaMustBeSynchronousError, but the error only surfaces at mutation time, not at collection creation'
127 source: 'packages/db/src/collection/mutations.ts:101'
128 priority: 'HIGH'
129 skills: ['collection-setup']
130​
131 - mistake: 'getKey returning undefined for some items'
132 mechanism: "If getKey returns undefined for any item, throws UndefinedKeyError; common when accessing a nested property that doesn't exist on all items"
133 source: 'packages/db/src/collection/mutations.ts:148'
134 priority: 'HIGH'
135 skills: ['collection-setup']
136​
137 - mistake: 'TInput not a superset of TOutput with schema transforms'
138 mechanism: 'When schema transforms types (e.g. string -> Date), the input type for mutations must accept the pre-transform type; mismatches cause type errors that are confusing because they reference internal schema types'
139 source: 'docs/guides/schemas.md - TInput must be superset of TOutput'
140 priority: 'HIGH'
141 skills: ['collection-setup']
142​
143 - mistake: 'Providing both explicit type parameter and schema'
144 mechanism: 'When a schema is provided, the collection infers types from it; also passing an explicit generic type parameter creates conflicting type constraints'
145 source: 'docs/overview.md - schema type inference note'
146 priority: 'MEDIUM'
147 skills: ['collection-setup']
148​
149 - mistake: 'React Native missing crypto.randomUUID polyfill'
150 mechanism: "TanStack DB uses crypto.randomUUID() internally for IDs; React Native doesn't provide this, causing runtime crash; must install react-native-random-uuid"
151 source: 'docs/overview.md - React Native section'
152 priority: 'HIGH'
153 skills: ['collection-setup']
154​
155 - mistake: 'Electric txid queried outside mutation transaction'
156 mechanism: "If pg_current_xact_id() is queried in a separate transaction from the actual mutation, the txid won't match the mutation's transaction, causing awaitTxId to stall forever; must query txid INSIDE the same SQL transaction as the mutation"
157 source: 'docs/collections/electric-collection.md - Debugging txid section'
158 priority: 'CRITICAL'
159 skills: ['collection-setup']
160​
161 - mistake: 'queryFn returning partial data without merging'
162 mechanism: 'queryFn result is treated as complete state; returning only new/changed items without merging with existing data causes all non-returned items to be deleted from the collection'
163 source: 'docs/collections/query-collection.md - Handling Partial/Incremental Fetches'
164 priority: 'CRITICAL'
165 skills: ['collection-setup']
166​
167 - mistake: 'Direct writes overridden by next query sync'
168 mechanism: 'Direct writes (writeInsert, etc.) update the collection immediately, but the next queryFn execution returns the complete server state which overwrites the direct writes; must coordinate staleTime and refetch behavior'
169 source: 'docs/collections/query-collection.md - Direct Writes and Query Sync'
170 priority: 'MEDIUM'
171 skills: ['collection-setup']
172​
173 - name: 'Live Queries'
174 slug: 'live-queries'
175 domain: 'live-queries'
176 description: 'Building SQL-like reactive queries across collections'
177 type: 'core'
178 covers:
179 - 'Query builder fluent API (.from, .where, .join, .select, .groupBy, .having, .orderBy, .limit, .offset, .distinct, .findOne)'
180 - 'Comparison operators (eq, ne, gt, gte, lt, lte, like, ilike, inArray, isNull, isUndefined)'
181 - 'Logical operators (and, or, not)'
182 - 'Aggregate functions (count, sum, avg, min, max)'
183 - 'String functions (upper, lower, length, concat, coalesce)'
184 - 'Math functions (add, subtract, multiply, divide)'
185 - 'Join types (inner, left, right, full)'
186 - 'Derived collections (query results are themselves collections)'
187 - 'createLiveQueryCollection (standalone queries outside components)'
188 - 'QueryIR (intermediate representation)'
189 - 'compileQuery (query compilation)'
190 - '$selected namespace for accessing SELECT fields in ORDER BY / HAVING'
191 - 'Predicate push-down (loadSubsetOptions for on-demand sync)'
192 - 'Incremental view maintenance via d2ts (differential dataflow)'
193 tasks:
194 - 'Filter collection items with complex WHERE conditions'
195 - 'Join two collections on a foreign key'
196 - 'Aggregate data with GROUP BY and HAVING'
197 - 'Sort and paginate query results'
198 - 'Create a derived collection from a query for reuse across components'
199 - 'Build a query with computed/projected fields'
200 - 'Use subqueries for complex data access patterns'
201 - 'Move JS array filtering/transformation logic into live queries for better performance'
202 reference_candidates:
203 - topic: 'Query operators'
204 reason: '>20 distinct operators (comparison, logical, aggregate, string, math) with signatures'
205 failure_modes:
206 - mistake: 'Using === instead of eq() in where clauses'
207 mechanism: 'JavaScript === in a where callback returns a boolean, not an expression object; the query silently evaluates to always-false or always-true instead of building the correct filter predicate. Throws InvalidWhereExpressionError.'
208 wrong_pattern: |
209 q.from({ users }).where(({ users }) => users.active === true)
210 correct_pattern: |
211 q.from({ users }).where(({ users }) => eq(users.active, true))
212 source: 'packages/db/src/query/builder/index.ts:375'
213 priority: 'CRITICAL'
214 skills: ['live-queries']
215​
216 - mistake: 'Filtering/transforming data in JS instead of using live query operators'
217 mechanism: "AI agents write .filter()/.map()/.reduce() on the data array instead of using the query builder's where/select/groupBy; this throws away incremental maintenance -- the JS code re-runs from scratch on every change, while the query only recomputes the delta"
218 wrong_pattern: |
219 const { data } = useLiveQuery(q => q.from({ todos }))
220 const active = data.filter(t => t.completed === false)
221 correct_pattern: |
222 const { data } = useLiveQuery(q =>
223 q.from({ todos }).where(({ todos }) => eq(todos.completed, false))
224 )
225 source: 'maintainer interview'
226 priority: 'CRITICAL'
227 skills: ['live-queries']
228​
229 - mistake: 'Not using the full set of available query operators'
230 mechanism: 'The library has a comprehensive operator set (string functions, math, aggregates, coalesce, etc.) but agents default to basic eq/gt/lt and do the rest in JS; every operator is incrementally maintained and should be preferred over JS equivalents'
231 source: 'maintainer interview'
232 priority: 'HIGH'
233 skills: ['live-queries']
234​
235 - mistake: 'Using .distinct() without .select()'
236 mechanism: 'distinct() deduplicates by the entire selected object shape; without select(), the shape is undefined, throwing DistinctRequiresSelectError'
237 source: 'packages/db/src/query/compiler/index.ts:218'
238 priority: 'HIGH'
239 skills: ['live-queries']
240​
241 - mistake: 'Using .having() without .groupBy()'
242 mechanism: 'HAVING filters aggregated groups; without GROUP BY there are no groups to filter, throwing HavingRequiresGroupByError'
243 source: 'packages/db/src/query/compiler/index.ts:293'
244 priority: 'HIGH'
245 skills: ['live-queries']
246​
247 - mistake: 'Using .limit() or .offset() without .orderBy()'
248 mechanism: 'Without deterministic ordering, limit/offset results are non-deterministic and cannot be incrementally maintained; throws LimitOffsetRequireOrderByError'
249 source: 'packages/db/src/query/compiler/index.ts:356'
250 priority: 'HIGH'
251 skills: ['live-queries']
252​
253 - mistake: 'Join condition using operator other than eq()'
254 mechanism: 'The D2 differential dataflow join operator only supports equality joins; using gt(), like(), etc. throws JoinConditionMustBeEqualityError'
255 source: 'packages/db/src/query/builder/index.ts:216'
256 priority: 'HIGH'
257 skills: ['live-queries']
258​
259 - mistake: 'Passing source directly instead of as {alias: collection}'
260 mechanism: 'from() and join() require sources wrapped as {alias: collection}; passing the collection directly throws InvalidSourceTypeError'
261 wrong_pattern: |
262 q.from(usersCollection)
263 correct_pattern: |
264 q.from({ users: usersCollection })
265 source: 'packages/db/src/query/builder/index.ts:79-96'
266 priority: 'MEDIUM'
267 skills: ['live-queries']
268​
269 - name: 'Framework Integration'
270 slug: 'framework-integration'
271 domain: 'framework-integration'
272 description: 'Binding live queries to UI framework components'
273 type: 'framework'
274 covers:
275 - 'React: useLiveQuery, useLiveSuspenseQuery, useLiveInfiniteQuery, usePacedMutations'
276 - 'Vue: useLiveQuery composable with computed refs'
277 - 'Svelte: useLiveQuery with Svelte 5 runes'
278 - 'Solid: useLiveQuery with fine-grained reactivity'
279 - 'Angular: injectLiveQuery with signals'
280 - 'Dependency arrays for reactive query parameters'
281 - 'React Suspense integration with Error Boundaries'
282 - 'Infinite query pagination (cursor-based)'
283 - 'Return shape: { data, state, collection, status, isLoading, isReady, isError }'
284 tasks:
285 - 'Bind a live query to a React component with useLiveQuery'
286 - 'Use React Suspense for loading states with useLiveSuspenseQuery'
287 - 'Implement infinite scroll with useLiveInfiniteQuery'
288 - 'Pass reactive parameters to queries in Vue (refs) / Angular (signals) / Solid (signals)'
289 - 'Set up dependency arrays for dynamic query parameters'
290 subsystems:
291 - name: 'React'
292 package: '@tanstack/react-db'
293 config_surface: 'useLiveQuery, useLiveSuspenseQuery, useLiveInfiniteQuery, usePacedMutations'
294 - name: 'Preact'
295 package: '@tanstack/preact-db'
296 config_surface: 'useLiveQuery, useLiveInfiniteQuery with derived query identity'
297 - name: 'Vue'
298 package: '@tanstack/vue-db'
299 config_surface: 'useLiveQuery composable with MaybeRefOrGetter'
300 - name: 'Svelte'
301 package: '@tanstack/svelte-db'
302 config_surface: 'useLiveQuery with Svelte 5 runes ($state)'
303 - name: 'Solid'
304 package: '@tanstack/solid-db'
305 config_surface: 'useLiveQuery with Accessor/createSignal'
306 - name: 'Angular'
307 package: '@tanstack/angular-db'
308 config_surface: 'injectLiveQuery with Signal, inject(DestroyRef)'
309 failure_modes:
310 - mistake: 'Missing external values in useLiveQuery dependency array'
311 mechanism: "When query uses external state (props, local state) not included in deps array, the query won't re-run when those values change, showing stale results"
312 wrong_pattern: |
313 const { data } = useLiveQuery(q =>
314 q.from({ todos }).where(({ todos }) => eq(todos.userId, userId))
315 ) // userId not in deps
316 correct_pattern: |
317 const { data } = useLiveQuery(q =>
318 q.from({ todos }).where(({ todos }) => eq(todos.userId, userId)),
319 [userId]
320 )
321 source: 'docs/framework/react/overview.md - dependency array section'
322 priority: 'CRITICAL'
323 skills: ['framework-integration']
324​
325 - mistake: 'Reading Solid signals outside the query function'
326 mechanism: "Solid's reactivity tracks signal reads inside the query function; reading signals before passing to useLiveQuery means changes aren't tracked and query won't re-run"
327 source: 'docs/framework/solid/overview.md - fine-grained reactivity section'
328 priority: 'HIGH'
329 skills: ['framework-integration']
330​
331 - mistake: 'Using useLiveSuspenseQuery without Error Boundary'
332 mechanism: 'Suspense query throws errors during rendering; without an Error Boundary wrapping the component, the entire app crashes instead of showing a fallback'
333 source: 'docs/guides/live-queries.md - React Suspense section'
334 priority: 'HIGH'
335 skills: ['framework-integration']
336​
337 - mistake: 'Passing non-function deps in Svelte instead of getter functions'
338 mechanism: 'In Svelte 5, props and derived values should be wrapped in getter functions in the dependency array to maintain reactivity; passing values directly captures them at creation time'
339 source: 'docs/framework/svelte/overview.md - Props in dependencies'
340 priority: 'MEDIUM'
341 skills: ['framework-integration']
342 compositions:
343 - library: 'meta-framework'
344 skill: 'meta-framework'
345​
346 - name: 'Mutations & Optimistic State'
347 slug: 'mutations-optimistic'
348 domain: 'mutations-optimistic'
349 description: 'Writing data to collections with instant optimistic feedback'
350 type: 'core'
351 covers:
352 - 'collection.insert(), collection.update(), collection.delete()'
353 - 'createOptimisticAction (custom mutation actions)'
354 - 'createPacedMutations (debounced/throttled mutations)'
355 - 'createTransaction (manual transaction control)'
356 - 'getActiveTransaction (ambient transaction context)'
357 - 'Transaction lifecycle (pending -> persisting -> completed | failed)'
358 - 'Transaction stacking (concurrent transactions build on each other)'
359 - 'Mutation merging (insert+update -> insert, insert+delete -> null, etc.)'
360 - 'onInsert, onUpdate, onDelete handlers'
361 - 'Optimistic vs non-optimistic updates (optimistic: false)'
362 - 'Automatic rollback on handler error'
363 - 'Change tracking proxy (draft updates via Immer-like API)'
364 - 'PendingMutation type (original, modified, changes, globalKey)'
365 - 'Transaction.isPersisted promise'
366 - 'Temporary ID handling'
367 - 'TanStack Pacer integration for sequential execution'
368 tasks:
369 - 'Insert a new item with optimistic UI update'
370 - 'Update an item using the draft proxy pattern'
371 - 'Delete items with automatic rollback on server error'
372 - 'Create a custom optimistic action for complex mutations'
373 - 'Use paced mutations for real-time text editing'
374 - 'Batch multiple mutations into a single transaction'
375 - 'Handle temporary IDs that get replaced by server-generated IDs'
376 - 'Use pacer for sequential transaction execution to avoid conflicts'
377 failure_modes:
378 - mistake: 'Passing a new object to update() instead of mutating the draft'
379 mechanism: "collection.update(id, {...item, title: 'new'}) is wrong; the API uses an Immer-style draft proxy: collection.update(id, (draft) => { draft.title = 'new' }). Passing an object instead of a callback silently fails or throws a confusing error."
380 wrong_pattern: |
381 collection.update(id, { ...item, title: 'new' })
382 correct_pattern: |
383 collection.update(id, (draft) => { draft.title = 'new' })
384 source: 'maintainer interview'
385 priority: 'CRITICAL'
386 skills: ['mutations-optimistic']
387​
388 - mistake: 'Hallucinating mutation API signatures'
389 mechanism: 'AI agents generate plausible but wrong mutation code -- inventing handler signatures, confusing createOptimisticAction with createTransaction, missing the ambient transaction pattern, or wrong PendingMutation property names (e.g. transaction.mutations[0].changes vs .data)'
390 source: 'maintainer interview'
391 priority: 'CRITICAL'
392 skills: ['mutations-optimistic']
393​
394 - mistake: 'onMutate callback returning a Promise'
395 mechanism: 'onMutate in createOptimisticAction must be synchronous because optimistic state needs to be applied immediately in the current tick; returning a Promise throws OnMutateMustBeSynchronousError'
396 wrong_pattern: |
397 createOptimisticAction({
398 onMutate: async (text) => { collection.insert({ id: await generateId(), text }) },
399 mutationFn: async (text, { transaction }) => { ... }
400 })
401 correct_pattern: |
402 createOptimisticAction({
403 onMutate: (text) => { collection.insert({ id: crypto.randomUUID(), text }) },
404 mutationFn: async (text, { transaction }) => { ... }
405 })
406 source: 'packages/db/src/optimistic-action.ts:75'
407 priority: 'CRITICAL'
408 skills: ['mutations-optimistic']
409​
410 - mistake: 'Calling insert/update/delete without handler or ambient transaction'
411 mechanism: 'Collection mutations require either an onInsert/onUpdate/onDelete handler or an ambient transaction from createTransaction; without either, throws MissingInsertHandlerError (or Update/Delete variant)'
412 source: 'packages/db/src/collection/mutations.ts:166'
413 priority: 'CRITICAL'
414 skills: ['mutations-optimistic']
415​
416 - mistake: 'Calling .mutate() after transaction is no longer pending'
417 mechanism: "Transactions can only accept new mutations while in 'pending' state; calling mutate() after commit() or rollback() throws TransactionNotPendingMutateError"
418 source: 'packages/db/src/transactions.ts:289'
419 priority: 'HIGH'
420 skills: ['mutations-optimistic']
421​
422 - mistake: "Attempting to change an item's primary key via update"
423 mechanism: 'The update proxy detects key changes and throws KeyUpdateNotAllowedError; primary keys are immutable once set'
424 source: 'packages/db/src/collection/mutations.ts:352'
425 priority: 'HIGH'
426 skills: ['mutations-optimistic']
427​
428 - mistake: 'Inserting item with duplicate key'
429 mechanism: 'If an item with the same key already exists in the collection (synced or optimistic), throws DuplicateKeyError; common when using client-generated IDs without checking'
430 source: 'packages/db/src/collection/mutations.ts:181'
431 priority: 'HIGH'
432 skills: ['mutations-optimistic']
433​
434 - mistake: 'Not awaiting refetch after mutation in query collection handler'
435 mechanism: "In query collection onInsert/onUpdate/onDelete handlers, the optimistic state is only held until the handler resolves; if you don't await the refetch or sync back, the optimistic state is dropped before new server state arrives, causing a flash of missing data"
436 wrong_pattern: |
437 onInsert: async ({ transaction }) => {
438 await api.createTodo(transaction.mutations[0].modified)
439 // missing: await collection.utils.refetch()
440 }
441 correct_pattern: |
442 onInsert: async ({ transaction }) => {
443 await api.createTodo(transaction.mutations[0].modified)
444 await collection.utils.refetch()
445 }
446 source: 'docs/overview.md - optimistic state lifecycle'
447 priority: 'HIGH'
448 skills: ['mutations-optimistic']
449​
450 - name: 'Meta-Framework Integration'
451 slug: 'meta-framework'
452 domain: 'meta-framework'
453 description: 'Client-side preloading of collections in route loaders for meta-frameworks'
454 type: 'composition'
455 covers:
456 - 'collection.preload() in route loaders'
457 - 'collection.stateWhenReady() and toArrayWhenReady()'
458 - 'collection.onFirstReady(callback)'
459 - 'Pre-creating createLiveQueryCollection in loaders'
460 - 'Setting ssr: false on routes using collections'
461 - 'TanStack Start / TanStack Router loader patterns'
462 - 'Coordinating collection lifecycle with route transitions'
463 - 'Passing pre-loaded collections to components via loader data'
464 tasks:
465 - 'Preload a collection in a TanStack Router route loader'
466 - 'Pre-create a live query collection in a loader and pass to component'
467 - 'Configure ssr: false on routes that use TanStack DB collections'
468 - 'Coordinate multiple collection preloads in a single route loader'
469 - 'Handle route transitions when collections are still loading'
470 failure_modes:
471 - mistake: 'Not preloading collections in route loaders'
472 mechanism: 'Without preload() in the loader, the collection starts syncing only when the component mounts; this causes a loading flash even though the router could have started the sync during navigation'
473 wrong_pattern: |
474 export const Route = createFileRoute('/todos')({
475 component: TodoList,
476 // no loader -- collection loads on mount
477 })
478 correct_pattern: |
479 export const Route = createFileRoute('/todos')({
480 component: TodoList,
481 ssr: false,
482 loader: async () => {
483 await todosCollection.preload()
484 },
485 })
486 source: 'examples/react/projects/src/routes'
487 priority: 'HIGH'
488 skills: ['meta-framework']
489​
490 - mistake: 'Not setting ssr: false on routes using collections'
491 mechanism: 'Collections are client-side only (no SSR support yet); rendering a route with collections on the server attempts to access browser-only APIs, causing crashes or hydration mismatches'
492 wrong_pattern: |
493 export const Route = createFileRoute('/todos')({
494 component: TodoList,
495 loader: async () => {
496 await todosCollection.preload()
497 },
498 })
499 correct_pattern: |
500 export const Route = createFileRoute('/todos')({
501 component: TodoList,
502 ssr: false,
503 loader: async () => {
504 await todosCollection.preload()
505 },
506 })
507 source: 'examples/react/projects/src/start.tsx - defaultSsr: false'
508 priority: 'CRITICAL'
509 skills: ['meta-framework']
510​
511 - mistake: 'Creating new collection instances inside loaders on every navigation'
512 mechanism: 'createLiveQueryCollection should be called once and reused; creating new instances on each navigation leaks D2 graph nodes and subscriptions'
513 source: 'docs/guides/live-queries.md - standalone queries'
514 priority: 'HIGH'
515 skills: ['meta-framework']
516 compositions:
517 - library: '@tanstack/react-router'
518 skill: 'framework-integration'
519​
520 - name: 'Custom Adapter Authoring'
521 slug: 'custom-adapter'
522 domain: 'custom-adapter'
523 description: 'Building custom collection adapters for new backends'
524 type: 'core'
525 covers:
526 - 'SyncConfig interface (sync, getSyncMetadata, rowUpdateMode)'
527 - 'Sync primitives (begin, write, commit, markReady, truncate)'
528 - 'ChangeMessage format (insert, update, delete)'
529 - 'loadSubset for on-demand sync mode'
530 - 'LoadSubsetOptions (where, orderBy, limit, cursor)'
531 - 'Expression parsing helpers (parseWhereExpression, parseOrderByExpression, extractSimpleComparisons)'
532 - 'Collection options creator pattern'
533 - 'Subscription lifecycle and cleanup'
534 tasks:
535 - 'Build a custom collection adapter for a new backend'
536 - 'Implement loadSubset for on-demand predicate push-down'
537 - 'Use expression parsing helpers to translate query predicates to API params'
538 - 'Handle the sync lifecycle correctly (begin/write/commit/markReady)'
539 failure_modes:
540 - mistake: 'Not calling markReady() in custom sync implementation'
541 mechanism: "markReady() transitions the collection from 'loading' to 'ready' status; forgetting to call it means live queries never resolve and useLiveSuspenseQuery hangs forever in Suspense"
542 wrong_pattern: |
543 sync: ({ begin, write, commit }) => {
544 fetchData().then(items => {
545 begin()
546 items.forEach(item => write({ type: 'insert', value: item }))
547 commit()
548 // forgot markReady()!
549 })
550 }
551 correct_pattern: |
552 sync: ({ begin, write, commit, markReady }) => {
553 fetchData().then(items => {
554 begin()
555 items.forEach(item => write({ type: 'insert', value: item }))
556 commit()
557 markReady()
558 })
559 }
560 source: 'docs/guides/collection-options-creator.md - markReady section'
561 priority: 'CRITICAL'
562 skills: ['custom-adapter']
563​
564 - mistake: 'Race condition between initial sync and event subscription'
565 mechanism: "If live change events aren't subscribed BEFORE the initial data fetch, changes that occur during the fetch are lost; the sync implementation must start listening before fetching"
566 wrong_pattern: |
567 sync: ({ begin, write, commit, markReady }) => {
568 // BAD: fetch first, then subscribe
569 const data = await fetchAll()
570 writeAll(data)
571 subscribe(onChange) // missed changes during fetch!
572 }
573 correct_pattern: |
574 sync: ({ begin, write, commit, markReady }) => {
575 // GOOD: subscribe first, then fetch
576 subscribe(onChange)
577 const data = await fetchAll()
578 writeAll(data)
579 }
580 source: 'docs/guides/collection-options-creator.md - Race condition prevention'
581 priority: 'HIGH'
582 skills: ['custom-adapter']
583​
584 - mistake: 'write() called without begin() in sync implementation'
585 mechanism: 'Sync data must be written within a transaction (begin -> write -> commit); calling write() without begin() throws NoPendingSyncTransactionWriteError'
586 source: 'packages/db/src/collection/sync.ts:110'
587 priority: 'HIGH'
588 skills: ['custom-adapter']
589​
590 - name: 'Offline Transactions'
591 slug: 'offline'
592 domain: 'offline'
593 description: 'Offline-first transaction queueing with persistence and retry'
594 type: 'composition'
595 covers:
596 - 'OfflineExecutor / startOfflineExecutor'
597 - 'OfflineConfig (collections, mutationFns, storage, maxConcurrency)'
598 - 'Storage adapters (IndexedDBAdapter, LocalStorageAdapter)'
599 - 'Retry policies (DefaultRetryPolicy, BackoffCalculator, NonRetriableError)'
600 - 'Leader election (WebLocksLeader, BroadcastChannelLeader)'
601 - 'Online detection (WebOnlineDetector)'
602 - 'OutboxManager (transaction queue)'
603 - 'KeyScheduler (prevents concurrent mutations on same key)'
604 - 'TransactionSerializer (persistence)'
605 - 'React Native support (@react-native-community/netinfo)'
606 tasks:
607 - 'Set up offline-first transactions with @tanstack/offline-transactions'
608 - 'Configure IndexedDB storage for transaction persistence'
609 - 'Handle multi-tab coordination with leader election'
610 - 'Implement custom retry logic with NonRetriableError'
611 - 'Set up offline support for React Native with NetInfo'
612 failure_modes:
613 - mistake: 'Using offline transactions when not needed'
614 mechanism: 'Offline is inherently complex; @tanstack/offline-transactions adds storage, leader election, and retry overhead. Only adopt when true offline support is required. PowerSync/RxDB handle their own local persistence, which is a different concern.'
615 source: 'maintainer interview'
616 priority: 'HIGH'
617 skills: ['offline']
618​
619 - mistake: 'Not handling NonRetriableError for permanent failures'
620 mechanism: 'By default, failed transactions retry with exponential backoff; for permanent failures (e.g. 400 Bad Request), throw NonRetriableError to skip retry and move the transaction to a dead-letter state'
621 source: 'packages/offline-transactions/src/retry.ts'
622 priority: 'HIGH'
623 skills: ['offline']
624​
625 - mistake: 'Multiple tabs executing the same queued transaction'
626 mechanism: 'Without leader election, each tab runs its own OfflineExecutor and processes the outbox independently, causing duplicate mutations; must configure WebLocksLeader or BroadcastChannelLeader'
627 source: 'packages/offline-transactions/src/leader/'
628 priority: 'CRITICAL'
629 skills: ['offline']
630​
631tensions:
632 - name: 'Simplicity vs. correctness in sync'
633 skills: ['collection-setup', 'custom-adapter']
634 description: 'Getting-started simplicity (localOnlyCollectionOptions, eager sync) conflicts with production correctness (on-demand sync, proper adapter selection, race condition prevention)'
635 implication: 'Agents use localOnly or eager mode for everything; production apps need adapter-specific patterns and on-demand sync for large datasets'
636​
637 - name: 'Optimistic speed vs. data consistency'
638 skills: ['mutations-optimistic', 'collection-setup']
639 description: 'Instant optimistic updates create a window where client state diverges from server state; resolving conflicts on rollback can lose user work'
640 implication: 'Agents apply optimistic updates without considering rollback UX or awaiting refetch in mutation handlers'
641​
642 - name: 'Query expressiveness vs. IVM constraints'
643 skills: ['live-queries', 'framework-integration']
644 description: "The query builder looks like SQL but has constraints (equality joins only, orderBy required for limit, no distinct without select) that SQL doesn't have"
645 implication: 'Agents write SQL-style queries that violate IVM constraints, producing confusing errors'
646​
647 - name: 'Offline complexity vs. app simplicity'
648 skills: ['offline', 'mutations-optimistic']
649 description: "Offline transaction support adds storage, leader election, and retry complexity; most apps don't need it but agents may recommend it prematurely"
650 implication: 'Agents add @tanstack/offline-transactions to apps that only need basic optimistic mutations'
651​
652cross_references:
653 - from: 'framework-integration'
654 to: 'meta-framework'
655 reason: 'Framework hooks render data; meta-framework loaders preload it. Developers need both for production apps with routing.'
656​
657 - from: 'meta-framework'
658 to: 'framework-integration'
659 reason: 'Preloaded collections are consumed by framework hooks; understanding the hook API informs what to preload.'
660​
661 - from: 'collection-setup'
662 to: 'mutations-optimistic'
663 reason: 'Collection mutation handlers (onInsert/onUpdate/onDelete) are configured at setup time but execute during mutations; understanding both is required for working writes.'
664​
665 - from: 'mutations-optimistic'
666 to: 'collection-setup'
667 reason: 'Mutation handler signatures and behavior depend on which adapter is used (e.g. Electric txid return, Query refetch).'
668​
669 - from: 'live-queries'
670 to: 'collection-setup'
671 reason: 'Live queries reference collections by alias; understanding collection types and sync modes affects query behavior (e.g. on-demand predicate push-down).'
672​
673 - from: 'custom-adapter'
674 to: 'collection-setup'
675 reason: 'Custom adapters produce the same CollectionConfig shape that built-in adapters use; understanding the config contract is essential.'
676​
677 - from: 'offline'
678 to: 'mutations-optimistic'
679 reason: 'Offline transactions wrap the same transaction/mutation model; understanding createTransaction and PendingMutation is prerequisite.'
680​
681gaps:
682 - skill: 'meta-framework'
683 question: 'What are the specific patterns for non-TanStack-Start frameworks (Next.js App Router, Remix loaders, Nuxt middleware, SvelteKit load functions)?'
684 context: 'Only TanStack Start/Router patterns are documented in examples; other frameworks need guidance'
685 status: 'open'
686​
687 - skill: 'collection-setup'
688 question: 'What is the recommended pattern for collection cleanup/disposal in single-page apps with route-based code splitting?'
689 context: "gcTime defaults to 5 minutes, but docs don't clearly explain when/how collections are garbage collected or what triggers cleanup"
690 status: 'open'
691​
692 - skill: 'live-queries'
693 question: 'Are there performance cliffs with live queries? At what complexity/data size do queries degrade?'
694 context: "Docs claim sub-millisecond for 100k items, but don't discuss limits (e.g., 5-way joins, deeply nested aggregations)"
695 status: 'open'
696​
697 - skill: 'mutations-optimistic'
698 question: 'What is the recommended pattern for handling temporary IDs that get replaced by server-generated IDs?'
699 context: "The mutations guide mentions temporary IDs but the pattern for mapping client IDs to server IDs during sync isn't well documented"
700 status: 'open'
701​
702 - skill: 'meta-framework'
703 question: 'What are the specific patterns for TanStack Router integration with collection loading/prefetching?'
704 context: 'Maintainer reports this is a major composition pain point; agents struggle with the loading/prefetching pattern'
705 status: 'open'
706​
707 - skill: 'offline'
708 question: 'What happens to in-flight transactions when the browser goes offline mid-persist?'
709 context: "The offline executor package handles queuing, but the interaction with the main transaction lifecycle isn't documented"
710 status: 'open'