Overview & Custom Adapters
1. The DataAdapter Interface
DataAdapter Interfaceimport type { DataAdapter, QueryParams, QueryResult, TableMetadata } from '@tablecraft/table';
export interface MyCustomAdapter<T> extends DataAdapter<T> {
// REQUIRED: Fetch data based on current table state
query: (params: QueryParams) => Promise<QueryResult<T>>;
// OPTIONAL: Fetch specific rows by ID (used for cross-page selection/export)
queryByIds?: (ids: (string | number)[]) => Promise<T[]>;
// OPTIONAL: Fetch schema metadata to auto-generate columns
meta?: () => Promise<TableMetadata>;
// OPTIONAL: Handle bulk data exports directly from the backend
export?: (format: "csv" | "json", params?: Partial<QueryParams>) => Promise<string>;
}The Request: QueryParams
QueryParamsThe Response: QueryResult
QueryResult2. Advanced: Custom UI State & External Filters
3. Frequently Asked Questions (FAQ)
Q: Does the Adapter pattern make DX complex?
Q: Does TableCraft's bundle get heavy because of all these adapters?
Q: My external API doesn't return the total row count (totalPages). How does TableCraft handle this?
totalPages). How does TableCraft handle this?Q: How do I handle authentication (JWTs) with my custom adapter?
Q: Why not just pass a simple fetchData function instead of a whole Adapter object?
fetchData function instead of a whole Adapter object?Last updated
Was this helpful?
