DataScript keeps a Datalog database inside the browser tab
Immutable database and Datalog query engine for Clojure, ClojureScript and JS
At a glance
- What is it?
- DataScript is an immutable in-memory database with a Datalog query engine, written in Clojure and ClojureScript, meant to be created on page load and discarded when the page closes. It answers questions about client state, and durable SQL storage implementations live in a separate project.
- Who is it for?
- DataScript fits a single-page ClojureScript app whose state is worth querying and worth rewinding, and where nothing needs to survive the tab. It does not fit anything that needs durability, remote queries, or a second writer, since persistence lives in separate repositories and every query stays inside the browser.
- Can I use it commercially?
- Yes, with conditions. EPL-1.0 is a weak copyleft licence: you can use it inside commercial and closed-source software, but if you distribute changes to its own files, you must publish those changes under the same licence.
- Is it still maintained?
- Yes. The repository last received commits 92 days ago.
- What is it written in?
- Mainly Clojure, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 14, 2026, and from our analysis. They are not legal advice.
Star history
- tonsky/datascript5,798 ★ · +7
| Repository | 2026-09-23 | 2026-11-14 |
|---|---|---|
| tonsky/datascript | 5.8k | 5.8k |
7 Stars in the last 52 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
The database lives in app state and dies with the page
DataScript is an immutable in-memory database with a Datalog query engine, written in Clojure and ClojureScript. The project opens with a question worth taking literally: what if creating a database were as cheap as creating a Hashmap? The databases are immutable and built on persistent data structures, and the README says they are more like data structures than databases, which is why the whole thing is meant to run inside the browser.
That framing sets the ceiling on what you get. The intended job is narrow and stated as such: a basic building block in client side applications that need to track a lot of state during their lifetime. You create a database on page load, put some data in it, track changes, do queries, and forget about it when the user closes the page. Cheap to create, quick to query, ephemeral. Those three adjectives are the contract.
So the first thing to verify is whether ephemeral is what you actually need. What the design does buy is one central, uniform place to manage application state, so that clients working with state come apart cleanly: rendering, server sync, and undo or redo do not interfere with each other. That separation is the reason to reach for an immutable value rather than a mutable handle, and it holds only as long as your app really is one tab in front of one server.
Queries end in a hashmap lookup, an array walk, or an index
The query engine is Datalog, and the account of what happens when you run one is deliberately plain. Querying comes down to a hashmap lookup, or a series of lookups, or array iteration, with no particular overhead attached to it. The README draws the size comparison itself: you put a little data in, it is fast; you put in a lot of data, at least it has indexes, and that should do better than you filtering an array by hand anyway. Indexes are the only lever offered for large data sets, and there is no claim about anything beyond that.
The stated benefit of the engine is answering non trivial questions about current app state, not serving as a general query surface. You also get a structured format for tracking data moving in and out of the database, and Datalog queries can be run against that too.
What the engine cannot do follows from where it runs. Every query executes against data already resident in the browser, so there is no distributed execution, no remote planner, and no query that reaches a database you did not copy in yourself. Note also how the query documentation is spread out: docs/queries.md and docs/tuples.md sit in the repository, while a triple stores overview points at Asami and a Datalog walkthrough lives on learndatalogtoday.org. Plan on reading across several places before you write your first non trivial clause.
Lein, deps.edn, and one compiler option shadow-cljs needs
Adding DataScript to a ClojureScript build is two lines in the version named by the project, 1.8.1. Lein users put the coordinate vector in project.clj:
;; lein
[datascript "1.8.1"]Tools.deps users put the lib and version pair in deps.edn:
;; deps.edn
datascript/datascript {:mvn/version "1.8.1"}Both build descriptors sit at the top of the repository, so the project is set up for either toolchain. If you build with shadow-cljs, the dependency line is not enough. You have to add a compiler option pointing at the externs file that ships with the library:
:compiler-options {:externs ["datascript/externs.js"]}The README calls this out as important and points at three tracked threads for it: issues 432 and 298, and pull request 216. What the library does not ask for is any runtime setup. There is no service to start, no port, no migration step, because nothing is loaded until your ClojureScript compiler runs.
Rewind is the payoff; the locking story is not
Immutability is what makes the rest of the design usable, and the benefits the project names are specific rather than abstract. You keep track of how application state evolved, you can rewind to any point in time, you can always render a consistent state, and you can sync in the background without locking anybody. Undo and redo fall out of holding old values rather than mutating in place, which is why the ToDo demo app advertises undo and redo as a feature rather than an add-on.
Read the concurrency claim carefully, because the scope is narrower than it first appears. The README frames all of this as simplifying things even in a single threaded browser environment. The absence of locking is a consequence of there being one thread, not evidence of a concurrency control design. What DataScript offers is that a value can be handed to rendering, to a sync routine, and to an undo stack at the same time without any of them writing over each other.
The README's overview does not set out a policy for merging two states produced by different writers. That work sits elsewhere in the ecosystem: DatSync is a separate project for Datomic to DataScript syncing and replication. Treat any merge semantics in your app as code you own, and check how Datomic or your server reconciles a value you did not write.
Persistence lives in sibling repositories, not in this one
Durable storage is the first thing a new user asks about. docs/storage.md is in the repository, while related projects add more: DataScript SQL Storages provides durable storage implementations for popular SQL databases, and DataScript-Transit handles transit serialization for a database and its datoms. Adding SQL-backed durability therefore means adding a second dependency.
The demo applications show what that ownership looks like in practice. The ToDo app persists through localStorage and transit, adds filtering, and keeps undo and redo on top. The CatChat demo is a chat app with a published code walkthrough. Those apps are the clearest available answer to how a DataScript value is meant to reach storage.
The integration layer is likewise split out. Posh lets a single DataScript database hold Reagent app state, and re-posh does the same for re-frame. DataScript-mori wraps DataScript and Mori for use from JavaScript. Datamaps applies datalog queries to arbitrary maps, and Intension converts associative structures into in-memory databases you can query. None of these ship inside the core library, so a project that needs queryable maps, JS access, or durable writes carries several dependencies, each with its own version to track.
Version 1.8.1 landed two days after 1.8.0
The release history is uneven in a way that affects pinning decisions. Version 1.7.8 shipped on 2025-10-11. Nothing followed for ten months, then 1.8.0 appeared on 2026-08-13 and 1.8.1 on 2026-08-15. The last push to the repository was on 2026-08-15, the same day as 1.8.1, and the project is not archived. The default branch is master and the license is EPL-1.0. So this is a project with recent work rather than a steady drip, which means the jump between the 1.7.x line and the 1.8.x line is the change your app actually evaluates, not the two day gap between 1.8.0 and 1.8.1.
Adoption spans a wide range of shapes, which sharpens that point. Roam Research uses it as a note taking graph database, LogSeq as a local first outliner notebook, Athens Research and Hulunote as tools for networked thought. LightMesh manages datacenters with it, PartsBox manages electronic parts, I am Fy sells accessories, and Precursor is a collaborative prototyping tool. Zetawar is a turn based tactical strategy game and Lemmings is an incubator focused on art and artificial intelligence.
Support goes to the #datascript channel on Clojurians Slack, with invites from clojurians.net. A Learning ClojureScript chapter covers the library, and cljdoc carries the API docs. None of that is a migration guide for the 1.7 to 1.8 jump, so read CHANGELOG.md at the pinned version before you move.
Editorial conclusion
DataScript fits a single-page ClojureScript app whose state is worth querying and worth rewinding, and where nothing needs to survive the tab. It does not fit anything that needs durability, remote queries, or a second writer, since persistence lives in separate repositories and every query stays inside the browser. Before committing, pin the version you read (1.8.1 is the one both dependency lines name), check that the shadow-cljs externs option is in your build if you use shadow-cljs, and read docs/storage.md if your state needs to survive the tab.
Frequently asked questions
How does DataScript store data inside a database?
A DataScript database is immutable and built on persistent data structures, so it behaves closer to a Hashmap than to a server database. A query resolves to a hashmap lookup, a series of lookups, or array iteration, and indexes do the work once you have put a lot of data in. In the intended browser use, the value is created on page load and discarded when the page closes.
What is DataScript used for in a browser application?
It is meant to be a basic building block for client side applications that track a lot of state during their lifetime. The stated benefits are one central, uniform place to manage application state, so that rendering, server sync, and undo or redo do not interfere with each other, plus a Datalog engine for non trivial questions about current app state and a structured format for data moving in and out of the database.
What is DataScript, and how do you add it to a build?
An immutable in-memory database and Datalog query engine for Clojure and ClojureScript, currently at version 1.8.1. Lein users add [datascript "1.8.1"] to project.clj and tools.deps users add datascript/datascript {:mvn/version "1.8.1"} to deps.edn. A shadow-cljs build also needs the externs compiler option pointing at datascript/externs.js, which the README flags as important and backs with issues 432, 298, and pull request 216.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/tonsky-datascript)Star history chart for your README
[](https://hysenlabs.com/projects/tonsky-datascript)Was this useful?