db-core/custom-adapter

Implement custom collection adapters to sync backends with TanStack DB.

3.9k|254|Updated Mar 11, 2025
One-click install
npx skills add https://github.com/TanStack/db --skill db-core-custom-adapter
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: db-core/custom-adapter
Source: https://github.com/TanStack/db/tree/main/packages/db/skills/db-core/custom-adapter
Command: npx skills add https://github.com/TanStack/db --skill db-core-custom-adapter

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Custom adapters let you plug new backends into TanStack DB without rewriting core logic, translating backend-specific data models into a unified collection API.

Core Features & Use Cases

  • On-demand sync with custom backends, including LoadSubset options and a persisted metadata API for per-row and per-collection state.
  • Rich change messaging and synchronization lifecycle support for Insert/Update/Delete flows.
  • Seamless integration with existing db-core tooling and patterns to accelerate backend integration and real-time data workflows.

Quick Start

Create a new backend adapter by implementing a CollectionConfig with a sync function that uses begin, write, commit, and markReady, then register the collection to start syncing.

Frequently Asked Questions about db-core/custom-adapter

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I integrate a custom backend with TanStack DB collections?

You create a custom adapter by implementing the SyncConfig interface with begin, write, commit, markReady, truncate, and metadata functions to translate backend data into a unified collection API. Register the collection to begin syncing.

What is on-demand subset syncing in a TanStack DB custom adapter?

On-demand subset syncing uses the loadSubset option within a custom adapter to fetch targeted backend data slices dynamically. This queries specific data into collections without requiring a full dataset synchronization.

How do I persist per-row sync metadata across restarts in a TypeScript backend?

You persist per-row and per-collection state across restarts by implementing the metadata function within the SyncConfig interface. This persisted metadata API ensures sync state survives diverse backend environment restarts.

Does TanStack DB support custom change message formats for Insert, Update, and Delete flows?

TanStack DB supports comprehensive ChangeMessage formats for Insert, Update, and Delete flows within custom adapters. The synchronization lifecycle processes these rich change messages to keep backend data aligned with local collections.

Do I need to implement the entire SyncConfig interface to create a database adapter?

Yes, creating a custom adapter requires implementing the SyncConfig interface, including begin, write, commit, markReady, truncate, and metadata functions. This ensures proper lifecycle management and metadata persistence for your backend.