@drasi/lib
Embed Drasi in your Node.js app
@drasi/lib runs Drasi's continuous-query engine in-process in Node.js — no servers, no brokers, no Kubernetes. Define sources and reactions in plain JavaScript, or load native Drasi plugins at runtime.
How @drasi/lib Works
Install the package, create Sources, Continuous Queries, and Reactions in code, and handle changes as they happen. Everything runs in-process — a native (napi-rs) addon hosts the embeddable Drasi engine inside Node, with prebuilt binaries for Windows, Linux (x64/arm64), and Apple-silicon macOS.
Push graph changes from your own application code into a JavaScript source, run a continuous query in Cypher or GQL, and receive the added, updated, and removed rows in a JavaScript reaction — all without leaving your Node.js process. When you need to connect to real systems, load Drasi’s native source, reaction, and bootstrap plugins at runtime, or pull them straight from the ghcr.io/drasi-project OCI registry.
When to Use @drasi/lib
@drasi/lib is ideal when you are building a Node.js application or service and need efficient, precise change detection without deploying separate infrastructure:
- Event-driven services — react to data changes without polling; get before/after states for every change.
- Real-time dashboards — stream live query results into a UI over your own channel (WebSocket, SSE, IPC).
- In-app reactive logic — replace complex event wiring with declarative continuous queries over your application state.
- Desktop apps — embed the engine directly in Electron’s main process (the addon is N-API v9, ABI-stable).
- Custom data pipelines — add reactive queries to ETL processes or stream processors.
Documentation
Everything you need to build with @drasi/lib, from a first continuous query to the full API surface.
Getting Started
Install the package and run your first continuous query in a couple of minutes.
Concepts
The change-driven model: sources, continuous queries, reactions, and synthetic joins.
API Reference
Every method on the Drasi class, grouped by area, with types.
Trading Demo
An end-to-end example joining a live price feed against a PostgreSQL database.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.