You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is no Rust implementation of IndexDB (there is a crate that appears to be squatting, but it really isn't an implementation). Servo does not support IndexedDB, they have a long standing issue to implement. So on the Rust front it is sort of a dead end.
In Node.js, there are no realistic implementations either. Again there is a package squatting on indexeddb, but it isn't really a good package at all. The one thing that seems to have promise is IndexedDBShim which sits on top of WebSQL, and there are native implementations of WebSQL on Node.js using sqlite3.
jsdom doesn't implement IndexedDB or WebSQL, though there is this issue talking about implementing the IndexedDB shim mentioned above, I assume requiring the WebSQL implementation. It looks like it is stalled.
There is what looks like a realistic Rust create for sqlite3.
So outside of using a C++ implementation, which would be a break in the pattern, the only realistic path I can easily see is that to use the in memory IndexedDB written in TypeScript, which would not give persistent storage, or we could adapt the in memory version and wire it up to a Rust sqlite3 bindings to persist the data.
I don't think just persisting out to JSON really works, because IndexedDB is a bit more complex than that, it contains concepts like transactions and other database features which is why almost all the browser implementations are based on sqlite3 IIRC.
Reacted by rektide, Danilo Fuchs, shynome and ngdangtu
Just updating this, servo still doesn't have it, and Gecko is looking at refactoring, but it is sqlite3 under the hoods. Here is a the most recent post that lays things out most relevantly: servo/servo#6963 (comment).
It would be really good to get localStorage/IndexedDB/kv-store in to Deno, IMO.
Reacted by Okku, Jan Johannes, Tim Reichen, DreamTexX and ngdangtu
@anlexN your comment is borderline abusive. The issue is well discussed here of how it is a complex issue. Please keep your conversation civil and on-topic.
Reacted by Albin Larsson, Carlos Ramos, Tim Reichen, shadowtime2000, hashrock, Danilo Fuchs, Serhii Mamedov, Moritz Hedtke, DreamTexX, KnorpelSenf and 8 more
HI, just exploring deno a bit, i thought (my mental model) is that deno implemented chromium aswell, (so it 100% compatible (as much as possible) with all webapis)
is the source code of the implementation of indexDB (firefox chrome) open sourced?
@jacobbogers Deno does not implement Chromium, it only implements V8. All the Web APIs need to be implemented independently. Chromium tends to implement these in C++ using the v8 binding to inject objects into the isolate.
Yes, both Firefox and Chromium are open source and their code is available, but that doesn't make it magically work for Deno.
@jacobbogers Deno does not implement Chromium, it only implements V8. All the Web APIs need to be implemented independently. Chromium tends to implement these in C++ using the v8 binding to inject objects into the isolate.
Yes, both Firefox and Chromium are open source and their code is available, but that doesn't make it magically work for Deno.
thanks for explaining, well at least if the source is avail (Firefox/Chrome) then we can kindof get some ideas /inspiration how to implement it,
IndexDB is a tuff nut to crack, it has transactions but has no explicit commit (its weird and ingenious way of doing transactions) this would not be easy to build from scratch.
@jacobbogers we have ideas/inspiration. One of the biggest factors was that we didn't have easy access to the V8 serialize/deserialize routines, which you need to support "structured cloning" which is needed to be able to store objects. We have that now. The other problem is the underlying DB as well as support under Rust. LevelDB (the one Google created and is in Chromium) is a bit of a mess. Firefox and Safari use SQLite as well as Servo looked at SQLite (can't remember how far they got). The biggest problem is the analogues between how Chromium and Firefox operate, and how Deno operates mean that there is very little overlap. For implementing web standards, we have had a lot better luck looking at a JavaScript shim/polyfill and the specification itself, than we have looking at other browser implementations.
There are the wpt for IndexedDB which helps ensure the standard is implemented correctly, and we now have the wpt integrated into our test process.
Reacted by Jacob Bogers, Eigil Sagafos, Danilo Fuchs and ͏
Hey everyone just reading the discussions. I think IndexDB for Deno might end up being used in more varied (or larger) ways than in a browser. For example, it is OK to expect data eviction in the browser, but if developers use IndexDB as a persistent backend store (like say SQLite) then the they might want further control of the underlying storage, its space allocation, path, etc.. Ability to backup/restore also comes to mind.
Maybe my thought process is incorrect, just that I felt it is perhaps a good time to share these now, before we have a ready implementation.
@crowlKats I have some interest in implementing this, but I don't want to take something away that you really want to do. If it is okay, should I start from your branch in #14035? Or just cut a fresh branch independent of yours and open a separate PR?
Now that Deno.KV is a thing, would it make sense to make IndexedDB a wrapper around the Deno.KV API instead of yet another SQLite? That way IndexedDB on Deno Deploy would take advantage of FoundationDB, and it would mean improvements to Deno.KV locally (see: #18657) would improve the IndexedDB implementation.
Reacted by Mark Fulton, Ankesh Bharti, Roman Heinrich, Michael J. Ryan, Lukas Heizmann, Adam Chalemian, Jan Johannes, josephrocca, Johan Lindkvist, QuantumGhost and 16 more
I needed this support for creating unit testing designed for the browser and tested by deno.
So this worked for me:
import{assertEquals}from"@std/assert";import{indexedDB}from"npm:fake-indexeddb@6.0.0";globalThis.indexedDB=indexedDB;// The actual implementation of the indexedDB APIs importLocalDataSourcefrom"LocalDataSource.ts";Deno.test(asyncfunctionLocalDataSourceTest(){assertEquals(1,1);});
@idofilus, as far as I know, npm:fake-indexeddb does not persist to disk which is something that would be desired from Deno built-in support. The more Deno runtime works like browser runtimes the easier it is to write universal code and the less APIs there are to learn and code against.
Reacted by Vladyslav Zubko, mhanuszh, takker, Lou Cyx and Matthew Conto
It's 2026 and most people use some sort of SQLite flavor. We have native support for node:sqlite and also Deno.KV which is built on top of SQLite. We're not gonna do IndexedDB after all.
Reacted by Óscar Otero, Matthew Conto, Jesse Jackson, Vladyslav Zubko, Tobias Buschor, Okku, Pete Hayman and Tim Reichen
@bartlomieju I think having IndexedDB is important and should remain as a feature request for browser parity.
I don't know what it would take to implement either on top of SQLite or via LevelDB, but as a JS/TS engine feature, I think it is a pretty wide miss at this point.
Reacted by Tobias Buschor, John Spurlock, Ido, Vladyslav Zubko and Tim Reichen
I'm gonna reopen this for now, but there's a slim chance we will implement this.
What do people want to use it for anyway?
Another major browser api that can be used in the code designed to run on browsers, with access to the all other of deno apis.
In my given case provided in this thread, I have a DataSource core class handling database related connection, e.g. mongodb MongoDataSource. Which I also allow the same core class as local storage, e.g. in the browser - this for example will be an offline database, with the option to sync against the remote e.g. mongo.
Since my server side is in Deno, and having that server side only code e.g. MongoDataSource I have the unit testing in it, now since it's the same DataSource core class, I made the unit testing on that class, and just creating the instances for the other inherited classes, therefore running a unit testing in deno to validate the browser's side LocalDataSource in the same pipeline.
The more browser apis in deno, the better "shared code" we can have, IndexedDB is quite useful for many use cases where compatibility of the code with the browser is required.
Reacted by John Spurlock, Michael J. Ryan, Vladyslav Zubko and Tim Reichen
Having support for IndexDB allows to write code that works on both front and backend and use libraries like Dexie.js or localForage that work on top of indexDB. It does a similar job as Deno.KV, but it's more standard, with more features and a bigger ecosystem. In fact, I think Deno.KV could be a @std library built on top of indexDB.
Reacted by Michael J. Ryan, Vladyslav Zubko, Okku, Lukas A. Santiago, Pete Hayman, Simon Lecoq and Tim Reichen
Activity
manyuanrong commentedon Feb 14, 2019
Should we use pure TS implementation or on the Rust side?
manyuanrong commentedon Feb 14, 2019
Or use ready-made C++ implementations
https://cs.chromium.org/chromium/src/content/browser/indexed_db/
kitsonk commentedon Mar 13, 2019
This is really complicated when you dig into it.
There is no Rust implementation of IndexDB (there is a crate that appears to be squatting, but it really isn't an implementation). Servo does not support IndexedDB, they have a long standing issue to implement. So on the Rust front it is sort of a dead end.
In Node.js, there are no realistic implementations either. Again there is a package squatting on indexeddb, but it isn't really a good package at all. The one thing that seems to have promise is IndexedDBShim which sits on top of WebSQL, and there are native implementations of WebSQL on Node.js using sqlite3.
jsdom doesn't implement IndexedDB or WebSQL, though there is this issue talking about implementing the IndexedDB shim mentioned above, I assume requiring the WebSQL implementation. It looks like it is stalled.
There is also an in memory IndexedDB API written in TypeScript.
There is what looks like a realistic Rust create for sqlite3.
So outside of using a C++ implementation, which would be a break in the pattern, the only realistic path I can easily see is that to use the in memory IndexedDB written in TypeScript, which would not give persistent storage, or we could adapt the in memory version and wire it up to a Rust sqlite3 bindings to persist the data.
I don't think just persisting out to JSON really works, because IndexedDB is a bit more complex than that, it contains concepts like transactions and other database features which is why almost all the browser implementations are based on sqlite3 IIRC.
kitsonk commentedon Apr 24, 2020
Just updating this, servo still doesn't have it, and Gecko is looking at refactoring, but it is sqlite3 under the hoods. Here is a the most recent post that lays things out most relevantly: servo/servo#6963 (comment).
It would be really good to get localStorage/IndexedDB/kv-store in to Deno, IMO.
anlexN commentedon May 18, 2020
kitsonk commentedon May 18, 2020
@anlexN your comment is borderline abusive. The issue is well discussed here of how it is a complex issue. Please keep your conversation civil and on-topic.
[-]IndexedDB[/-][+]Add support for IndexedDB[/+]jacobbogers commentedon Apr 6, 2021
HI, just exploring deno a bit, i thought (my mental model) is that deno implemented chromium aswell, (so it 100% compatible (as much as possible) with all webapis)
is the source code of the implementation of indexDB (firefox chrome) open sourced?
kitsonk commentedon Apr 6, 2021
@jacobbogers Deno does not implement Chromium, it only implements V8. All the Web APIs need to be implemented independently. Chromium tends to implement these in C++ using the v8 binding to inject objects into the isolate.
Yes, both Firefox and Chromium are open source and their code is available, but that doesn't make it magically work for Deno.
jacobbogers commentedon Apr 7, 2021
thanks for explaining, well at least if the source is avail (Firefox/Chrome) then we can kindof get some ideas /inspiration how to implement it,
IndexDB is a tuff nut to crack, it has transactions but has no explicit commit (its weird and ingenious way of doing transactions) this would not be easy to build from scratch.
kitsonk commentedon Apr 7, 2021
@jacobbogers we have ideas/inspiration. One of the biggest factors was that we didn't have easy access to the V8 serialize/deserialize routines, which you need to support "structured cloning" which is needed to be able to store objects. We have that now. The other problem is the underlying DB as well as support under Rust. LevelDB (the one Google created and is in Chromium) is a bit of a mess. Firefox and Safari use SQLite as well as Servo looked at SQLite (can't remember how far they got). The biggest problem is the analogues between how Chromium and Firefox operate, and how Deno operates mean that there is very little overlap. For implementing web standards, we have had a lot better luck looking at a JavaScript shim/polyfill and the specification itself, than we have looking at other browser implementations.
There are the wpt for IndexedDB which helps ensure the standard is implemented correctly, and we now have the wpt integrated into our test process.
brainless commentedon May 25, 2021
Hey everyone just reading the discussions. I think IndexDB for Deno might end up being used in more varied (or larger) ways than in a browser. For example, it is OK to expect data eviction in the browser, but if developers use IndexDB as a persistent backend store (like say SQLite) then the they might want further control of the underlying storage, its space allocation, path, etc.. Ability to backup/restore also comes to mind.
Maybe my thought process is incorrect, just that I felt it is perhaps a good time to share these now, before we have a ready implementation.
kitsonk commentedon May 25, 2021
Then that isn't IndexedDB, that is a native SQLite plugin.
27 remaining items
idranme commentedon Jul 13, 2023
I'm kind of looking forward to it.
alexgleason commentedon Jul 23, 2023
Now that Deno.KV is a thing, would it make sense to make IndexedDB a wrapper around the Deno.KV API instead of yet another SQLite? That way IndexedDB on Deno Deploy would take advantage of FoundationDB, and it would mean improvements to Deno.KV locally (see: #18657) would improve the IndexedDB implementation.
idofilus commentedon Mar 31, 2025
I needed this support for creating unit testing designed for the browser and tested by deno.
So this worked for me:
mfulton26 commentedon Mar 31, 2025
@idofilus, as far as I know,
npm:fake-indexeddbdoes not persist to disk which is something that would be desired from Deno built-in support. The more Deno runtime works like browser runtimes the easier it is to write universal code and the less APIs there are to learn and code against.bartlomieju commentedon May 3, 2026
It's 2026 and most people use some sort of SQLite flavor. We have native support for
node:sqliteand alsoDeno.KVwhich is built on top of SQLite. We're not gonna do IndexedDB after all.alexgleason commentedon May 3, 2026
This is one of the few things in 2026 that could make Deno more appealing than Bun
tracker1 commentedon May 4, 2026
@bartlomieju I think having IndexedDB is important and should remain as a feature request for browser parity.
I don't know what it would take to implement either on top of SQLite or via LevelDB, but as a JS/TS engine feature, I think it is a pretty wide miss at this point.
bartlomieju commentedon May 4, 2026
I'm gonna reopen this for now, but there's a slim chance we will implement this.
What do people want to use it for anyway?
idofilus commentedon May 4, 2026
Another major browser api that can be used in the code designed to run on browsers, with access to the all other of deno apis.
In my given case provided in this thread, I have a
DataSourcecore class handling database related connection, e.g. mongodbMongoDataSource. Which I also allow the same core class as local storage, e.g. in the browser - this for example will be an offline database, with the option to sync against the remote e.g. mongo.Since my server side is in Deno, and having that server side only code e.g.
MongoDataSourceI have the unit testing in it, now since it's the sameDataSourcecore class, I made the unit testing on that class, and just creating the instances for the other inherited classes, therefore running a unit testing in deno to validate the browser's sideLocalDataSourcein the same pipeline.The more browser apis in deno, the better "shared code" we can have, IndexedDB is quite useful for many use cases where compatibility of the code with the browser is required.
alexgleason commentedon May 4, 2026
I want to test my browser libraries.
oscarotero commentedon May 4, 2026
Having support for IndexDB allows to write code that works on both front and backend and use libraries like Dexie.js or localForage that work on top of indexDB. It does a similar job as Deno.KV, but it's more standard, with more features and a bigger ecosystem. In fact, I think Deno.KV could be a
@stdlibrary built on top of indexDB.