Skip to content

API Reference

Use this page to find a public API by package. The generated reference contains signatures for every exported core, datastore, React, and plugin entry point; task-focused pages explain behavior and combinations.

@routier/datastore

ts
import { DataStore, Collection, Queryable } from "@routier/datastore";

DataStore

MemberPurpose
new DataStore(plugin, options?)Construct a store; normally called by a subclass
collection(schema)Protected collection-builder entry point
view(schema)Protected view-builder entry point
schemasRead-only collection of schemas registered by this store
getCollection(schema)Resolve a configured collection by schema
getDbPlugin<T>()Access the configured plugin/stack
saveChanges(done) / saveChangesAsync()Persist every pending collection change
previewChanges(done) / previewChangesAsync()Inspect pending changes without saving
hasChanges(done) / hasChangesAsync()Test whether any collection is dirty
destroy(done) / destroyAsync()Destroy the underlying database and dispose the store
[Symbol.dispose]()Abort subscriptions and release this store without deleting the database

DataStoreOptions has crossTabSync?: boolean (default true) and semiJoinKeyThreshold?: number (default 500).

Collection builder

A declaration is collection(schema) → features → mode → create():

  • Features: scope, softDelete, audit(...).derive(...), fullTextSearch.
  • Modes: proxy, diff, immutable, readonly.
  • Construction: create() or create(factory) for a custom subclass.

See Configuring Collections for the complete compatibility and behavior table.

Collection and query surface

GroupMembers
Createinstance, add/addAsync (writable modes)
Updatedirect mutation (proxy, diff); update, current, isCurrent (immutable)
Deleteremove/removeAsync, removeAll/removeAllAsync (writable modes)
Composewhere, sort, sortDescending, skip, take, map, nearest, search, join, leftJoin, toQueryable, apply
Reusable queryQueryable.compose(schema) builds a definition; collection.apply(composer) attaches it
ExecutetoArray, first, firstOrUndefined, some, every, min, max, sum, count, distinct, toGroup and each *Async form
Live querysubscribe() followed by a terminal method; the terminal callback returns an unsubscribe function
TrackinghasChanges, tag, tags, attachments
Search maintenancefullTextSearch.check(), fullTextSearch.rebuild()

Most filters have plain and parameterized overloads:

ts
store.products.where(p => p.active).toArrayAsync();
store.products.where((p, q) => p.price >= q.min, { min: 10 }).toArrayAsync();

Start with Queries, Reusable Queries, and Terminal Methods.

@routier/core

The root export mirrors the public subpath exports below. Prefer a focused subpath when it makes dependencies clearer.

ImportMain API
@routier/core/schemas, schema/property classes, InferType, InferCreateType, SchemaDefinition, property metadata
@routier/core/pluginsIDbPlugin, events, query options, translators, CacheDbPlugin, RetryDbPlugin, ConcurrencyDbPlugin, BatchingDbPlugin, TelemetryDbPlugin
@routier/core/expressionsExpression types, parsing, evaluation, query filter types
@routier/core/collectionsPersist change/result buckets, schema collections, in-memory collection primitives
@routier/core/resultsResult, PluginEventResult, callback/result types and helpers
@routier/core/errorsSchemaError, OptimisticConcurrencyError, PluginDestroyedError
@routier/core/assertionsRuntime assertions and expression type guards
@routier/core/utilitiesIDs, hashing, cloning, logger, runtime and collection helpers
@routier/core/pipelineTrampolinePipeline, SyncronousQueue
@routier/core/performancenow, measure
@routier/core/typesShared utility types

The schema factories and valid modifier combinations are listed in Schema API. Generic wrapper behavior is in Wrapper Plugins.

@routier/react

ts
import { useQuery } from "@routier/react";

const result = useQuery(
  () => store.products.where(p => p.active).subscribe().toArray,
  [store]
);

useQuery(queryFactory, deps) executes a Routier callback query, manages its unsubscribe handler, and returns { status, data?, error? }. See React Hooks.

Plugin packages

PackagePrimary exports
@routier/memory-pluginMemoryPlugin, MemoryDatabase, assertIsMemoryPlugin
@routier/browser-storage-pluginBrowserStoragePlugin
@routier/dexie-pluginDexiePlugin
@routier/file-system-pluginFileSystemPlugin, FileSystemDbCollection
@routier/sqlite-pluginSqliteDbPlugin, driver interfaces; subpaths for sqlite3, Turso, and D1
@routier/postgresql-pluginPostgresDbPlugin, config/SQL result types, PostgresSqlTranslator
@routier/mysql-pluginMysqlDbPlugin, config/SQL result types
@routier/mongodb-pluginMongoDbPlugin, MongoClientDriver, MQL translation and driver interfaces
@routier/pouchdb-pluginPouchDbPlugin and sync/design-document types
@routier/replication-pluginHTTP, SWR, optimistic, transport, sync engine, auth/dead-letter types
@routier/blob-pluginS3Plugin, DirectUploadPlugin, BlobDbPlugin, file references and blob-store contracts
@routier/encryptioncreateKeyring, encryption, keyring types, isEnvelope
@routier/sql-plugin-coreSQL dialect, query, column, update, and join helpers for plugin authors

See the Plugin Catalog for setup and selection.

Generated reference

Run npm run typedoc at the repository root after changing a public export or JSDoc. It generates reference pages from all package entry points in typedoc.json.

Released under the MIT License.