Embedded only
Mastra is an open-source TypeScript framework for building AI agents, workflows, and retrieval-augmented generation (RAG) pipelines. Its official @mastra/lance package connects Mastra to LanceDB Embedded on local disk with no separate database server.
Installation
@mastra/lance requires Node.js 22.13.0 or later and depends on @mastra/core. Install both packages:
@mastra/lance also installs @lancedb/lancedb and the matching native binary for your platform.
Vector search quickstart
Save the following script asexample.mjs. It opens a local LanceDB directory with LanceVectorStore.create(), creates a documents table, upserts two 3-dimensional vectors, and runs a nearest-neighbor query:
example.mjs
lancedb with a cosine similarity score of 1:
Output
Native vector index
The firstcreateIndex() call initializes an empty LanceDB table without building a native vector index. When tableName is omitted, indexName sets the table name and vector is the vector column. Queries work on small tables immediately through flat scan.
To build a native LanceDB vector index when extending the quickstart, call createIndex() again after upserting at least 256 rows and before store.close():
TypeScript
indexConfig.type values include "ivfflat", "ivfpq", and the default HNSW PQ index.
Application storage and references
@mastra/lance also exports LanceStorage for Mastra agent memory and workflow state. The published LanceStorage.create(id, name, uri) factory takes three required arguments (id, name, and uri). See the released LanceStorage.create implementation for the current signature if you encounter older two-argument examples.