Lattice SDK Documentation
Build type-safe, composable data layers for modern applications.
Getting Started
Install Lattice SDK via your preferred package manager. The SDK requires Node.js 18 or later and supports both ESM and CommonJS module formats.
$ npm install @lattice/sdk
After installation, initialize your Lattice client by providing your schema definition and connection parameters. The client auto-discovers your data sources and builds an optimized query planner at startup.
// Initialize the client
import { LatticeClient } from '@lattice/sdk';
const client = new LatticeClient({
schema: './schema.lattice',
endpoint: 'https://api.example.com',
});
API Reference
client.query()
Execute a read operation against your data layer. Supports filtering, pagination, field selection, and nested relation loading with automatic batching.
Returns: Promise<QueryResult>client.mutate()
Perform create, update, or delete operations with built-in optimistic locking. Mutations are validated against your schema before execution.
Returns: Promise<MutationResult>client.subscribe()
Open a real-time subscription to data changes. Uses WebSocket transport with automatic reconnection and message ordering guarantees.
Returns: Subscriptionclient.batch()
Group multiple operations into an atomic batch. All operations succeed or fail together, with automatic rollback on partial failure.
Returns: Promise<BatchResult>Code Examples
Fetch a paginated list of users with their associated organizations, applying a filter on account status.
const users = await client.query('User', {
filter: { status: 'active' },
include: ['organization'],
pagination: { page: 1, perPage: 25 },
orderBy: { createdAt: 'desc' },
});
// Result: { data: User[], meta: { total: 142, page: 1 } }
Changelog
v3.2.1 — February 2026
Fixed edge case in batch rollback when using nested transactions. Improved WebSocket reconnection stability.
v3.2.0 — January 2026
Added support for computed fields in schema definitions. New caching middleware with TTL-based invalidation.
v3.1.0 — December 2025
Introduced plugin system for extending client behavior. Added official Auth, Logger, and Metrics plugins.