DEV.co
Open-Source Databases · tonsky

datascript

DataScript is an immutable, in-memory Datalog query engine designed for browser and JavaScript environments. It provides a lightweight alternative to traditional databases for managing client-side application state with Clojure/ClojureScript semantics.

Source: GitHub — github.com/tonsky/datascript
5.8k
GitHub stars
317
Forks
Clojure
Primary language
EPL-1.0
License (Requires review (not clearly OSI))

Key facts

Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.

FieldValue
Repositorytonsky/datascript
Ownertonsky
Primary languageClojure
LicenseEPL-1.0 — Requires review (not clearly OSI)
Stars5.8k
Forks317
Open issues80
Latest release1.7.8 (2025-10-11)
Last updated2025-10-11
Sourcehttps://github.com/tonsky/datascript

What datascript is

An immutable database built on persistent data structures (similar to Clojure's Hashmap) that compiles to JavaScript and supports Datalog queries. It tracks application state changes, provides indexed lookups, and enables time-travel semantics through immutability.

Quickstart

Get the datascript source

Clone the repository and explore it locally.

terminalbash
git clone https://github.com/tonsky/datascript.gitcd datascript# follow the project's README for install & configuration

Need it deployed, integrated, or customized instead? DEV.co ships production installs.

Best use cases

Browser-based state management with complex queries

Centralized, uniform state management for single-page applications requiring non-trivial queries against in-memory data without server round-trips.

Applications requiring undo/redo and state evolution tracking

Immutable architecture naturally supports rewind-to-any-point-in-time semantics and consistent state rendering across time.

Knowledge management and graph database UIs

Production adoption by Roam Research, LogSeq, and Athens Research demonstrates suitability for networked/graph-structured data in interactive applications.

Implementation considerations

  • Requires ClojureScript or JavaScript compiled version; primary language is Clojure, so Clojure codebases benefit most.
  • Shadow-cljs users must configure externs compiler option; documented but adds build complexity.
  • Immutable semantics mean familiar SQL patterns (UPDATE, DELETE) require transaction-based state replacement.
  • No built-in persistence; integrate with localStorage, IndexedDB, or external storage separately.
  • Datalog query syntax differs from SQL; team must learn predicate logic and join semantics.

When to avoid it — and what to weigh

  • Server-side or durable persistence is primary requirement — DataScript is ephemeral by design—intended for browser memory. While SQL storage adapters exist, they are separate projects and not the primary use case.
  • Team lacks Clojure/Lisp experience — Datalog syntax and Clojure semantics create a learning curve. Teams unfamiliar with functional programming patterns may find adoption slower.
  • Need for horizontal scaling or distributed state — Single-process, in-memory architecture; not designed for distributed systems or multi-machine deployment.
  • Performance-critical with very large datasets (>100MB+) — While indexed, performance degrades with large volumes. Designed for 'a little data' to moderate datasets in browser contexts.

License & commercial use

Eclipse Public License 1.0 (EPL-1.0). Permissive copyleft license compatible with most open-source projects. Permits use, modification, and distribution; requires preservation of license headers and offers patent protection to contributors.

EPL-1.0 is a recognized OSI-approved permissive license. Commercial use is permitted without seeking additional permission. Derivative works must remain under EPL-1.0. Production adoption by commercial projects (Roam Research, LogSeq, PartsBox, etc.) confirms commercial viability. Recommend legal review of specific use case if bundling/relicensing occurs.

DEV.co evaluation signals

Editorial assessment — not user reviews. Directional, with an explicit confidence level.

SignalAssessment
MaintenanceActive
DocumentationStrong
License clarityClear
Deployment complexityLow
DEV.co fitGood
Assessment confidenceHigh
Security considerations

In-memory database; no network exposure by default. No authentication/authorization layer—applications must implement access control at query/transaction level if needed. Datalog injection possible if queries constructed from untrusted input; treat query construction similarly to SQL (parameterize). No known CVEs noted in data; review security issue tracker if integrating into security-sensitive context. Immutability mitigates certain state-corruption attacks.

Alternatives to consider

Datomic (or Datomic Free)

Full-featured distributed database with Datalog support; heavier weight, requires server. Better if you need durability and distributed features; DataScript lighter if client-only state suffices.

Recoil, Zustand, or Redux (JavaScript state managers)

Simpler, broader ecosystem, no Datalog learning curve. Use if queries are simple (selectors/derived state) and Clojure integration is not a goal.

SQLite WASM

Durable, SQL-based, runs in browser. Use if you need persistence and SQL familiarity; DataScript if you prefer Datalog semantics and immutable architecture.

Software development agency

Build on datascript with DEV.co software developers

DataScript powers production apps like Roam Research and LogSeq. Get expert guidance on integration, architecture, and custom development.

Talk to DEV.co

Related open-source tools

Surfaced by semantic similarity across the DEV.co open-source index.

Related on DEV.co

Explore the category and the services that help you build with it.

datascript FAQ

Can I persist DataScript databases to disk?
DataScript is ephemeral by design. Use localStorage, IndexedDB, or external storage libraries. The separate datascript-storage-sql project provides SQL backend integration but is not part of core.
Is DataScript suitable for real-time collaborative apps?
Unknown without reviewing architectural patterns. Immutability supports concurrent writes and time-travel, but no built-in conflict resolution or multi-user sync. DatSync project suggests some integration patterns exist; evaluate for your use case.
What JavaScript environments are supported?
Compiled to JavaScript via ClojureScript; works in browsers and Node.js (though primarily designed for browser). Vanilla JS usage supported via compiled bundle; see GitHub releases for pre-built artifacts.
How does DataScript handle schema evolution?
Schema passed on database creation (see examples). Immutable semantics mean schema changes require new database or transaction-based transformation. Not as seamless as dynamic SQL ALTER TABLE; design schema upfront or implement migration logic.

Software developers & web developers for hire

DEV.co is a software development agency delivering custom software development services to companies building on open source. Our software developers and web developers design, integrate, and ship production systems — spanning web development, APIs, AI, data, and cloud. If datascript is part of your open-source databases roadmap, our team can implement, customize, migrate, and maintain it.

Evaluate DataScript for Your Client-Side State Needs

DataScript powers production apps like Roam Research and LogSeq. Get expert guidance on integration, architecture, and custom development.