TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

SQLite Wasm in the browser backed by the Origin Private File System

372 pointsby bubblehack3rover 2 years ago

22 comments

mckravchykover 2 years ago
I think this will be great for extensions. Currently the only solid choice is to use the dead simple storage.local which only allows to retrieve things by ID.<p>There&#x27;s one problem though, this new API is for the web, so the nature of this storage is temporary - obviously the user must be able to clear it when clearing site data and this what makes it currently an unviable solution for a persistent extensions data storage. <a href="https:&#x2F;&#x2F;bugs.chromium.org&#x2F;p&#x2F;chromium&#x2F;issues&#x2F;detail?id=1383216" rel="nofollow">https:&#x2F;&#x2F;bugs.chromium.org&#x2F;p&#x2F;chromium&#x2F;issues&#x2F;detail?id=138321...</a>
评论 #34359618 未加载
评论 #34363088 未加载
评论 #34363735 未加载
评论 #34362628 未加载
评论 #34358436 未加载
DylanSpover 2 years ago
Does anyone have hands-on experience with how well different browsers support this? This blog post and caniuse both say Chrome support is currently somewhat limited (though being improved); caniuse also mentions that Safari (both desktop and iOS) only support the Origin Private File System part of the File System API, and that Firefox doesn&#x27;t support it all. I&#x27;m curious how all that actually shakes out in practice.
评论 #34356016 未加载
评论 #34355596 未加载
评论 #34357164 未加载
评论 #34355481 未加载
samwillisover 2 years ago
This is a nice overview!<p>Discussion from back when the SQLite project announced this last year: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=33374402" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=33374402</a><p>There isn&#x27;t an &quot;official&quot; NPM package or ES6 model yet, but I believe they are working on it. It&#x27;s also very much designed for the browser currently, but again I believe they are intending to support server WASM environments too eventually.
评论 #34357650 未加载
评论 #34355130 未加载
estover 2 years ago
TIL OPFS.<p><a href="https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;API&#x2F;File_System_Access_API#origin_private_file_system" rel="nofollow">https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;API&#x2F;File_System...</a><p>What&#x27;s next, mmap() for javascript?
评论 #34354706 未加载
评论 #34354747 未加载
评论 #34361169 未加载
评论 #34358203 未加载
评论 #34362856 未加载
评论 #34354537 未加载
Zuiiiover 2 years ago
The custom header requirement will make this version of sqlite unusable for many usecases. Can SQLite fallback to using slower persistant APIs if neither Cross-Origin-Opener-Policy or Origin-Embedder-Policy are set? If not, does the SQLite project intend to provide a version that would?<p>Devs who don&#x27;t need the high performance but want wider compatibility will probably continue to use the &quot;unofficial&quot; versions.<p>Also, last I checked, you could definitely load web assembly in a page that has a File:&#x2F;&#x2F;&#x2F; origin.
smallerfishover 2 years ago
Very nice. I hope Firefox end up supporting OPFS.<p>My use case is an entirely offline webapp that I&#x27;m building as a side project, partly just to see what is possible. I&#x27;ve tried indexeddb, pouchdb, absurd-sql, and various others, and have ended up back at localstorage, which is plain but low on edge cases.<p>The other big pain point I am hacking around is cross device sync; I&#x27;m leaning towards simple chrome and firefox extensions that&#x27;ll slurp data into your profile in order to sync, which&#x27;ll work for cross computer sync for my needs. However, chrome on android doesn&#x27;t support extensions, and there&#x27;s no other good way that I&#x27;ve found to sync between a user&#x27;s chrome profile and android, so that is still a hole in the story. Some kind of webrtc based thing is imaginable, but it&#x27;s clunky.
评论 #34356239 未加载
Keltesethover 2 years ago
Fun fact: The headline image is the Stadtbibliothek Stuttgart, the nicest library I ever visited: <a href="https:&#x2F;&#x2F;www.archdaily.com&#x2F;193568&#x2F;stuttgart-city-library-yi-architects" rel="nofollow">https:&#x2F;&#x2F;www.archdaily.com&#x2F;193568&#x2F;stuttgart-city-library-yi-a...</a>
评论 #34356082 未加载
gfodorover 2 years ago
Ironically I was just about to drop in absurd-sql [1] to a project, which uses indexeddb to back SQLite. This seems better.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;jlongster&#x2F;absurd-sql">https:&#x2F;&#x2F;github.com&#x2F;jlongster&#x2F;absurd-sql</a>
评论 #34355258 未加载
评论 #34354512 未加载
评论 #34354996 未加载
throwaway284534over 2 years ago
This is honestly very cool. VS Code uses a similar approach to their local file system provider, albeit with a wrapper around IndexDB instead of SQLite. There’s some interesting trade offs too, since IndexDB can store the browser’s native file handlers in a flat map — so there’s no need for a schema.<p>IMO, the Chrome team is being a bit deceptive with their phrasing on synchronous file handles. The problem is that the entire API is wrapped up in an asynchronous ceremony. `createSyncAccessHandle` is only available in a worker context. So you can only communicate with the worker using an asynchronous postMesssage event dispatcher. And even when you’re in the worker, file handles can only be accessed through methods that return a promise.<p>I understand the need for such boundaries when working with a single threaded language, but limiting the synchronous APIs to just workers seems like one too many layers of indirection. I recently attempted to write a POSIX-style BusyBox library and this sort of thing was a total show stopper.
评论 #34356558 未加载
rektideover 2 years ago
I have yet to see whether implementations allow users direct access via the filesystem to these contents. The idea of each origin having some files sounds fine. But if I genuinely want to help &amp; empower my users, give them the most user agency, I&#x27;d want them to be able to access the sqlite sb themselves directly, with whatever hazards they thereby assume.
评论 #34354814 未加载
typingmonkeyover 2 years ago
Using SQLite in the browser is great until you have users that open your app in more then one browser tab.
评论 #34355315 未加载
评论 #34355149 未加载
评论 #34355603 未加载
评论 #34355557 未加载
评论 #34359281 未加载
评论 #34355323 未加载
msieover 2 years ago
I was so disappointed when sqlite&#x2F;websql was ditched in favour of IndexedDB. What were they thinking? Too smart for their own good?
评论 #34364096 未加载
tristanhoover 2 years ago
Does anyone have a good idea of when OPFS will be broadly available in all major browsers? And what&#x27;s best to use as a pseudo-polyfill in the mean time?<p>Something relevant is absurd-sql, but unfortunately that&#x27;s not even close to production ready :&#x2F;<p><a href="https:&#x2F;&#x2F;github.com&#x2F;jlongster&#x2F;absurd-sql">https:&#x2F;&#x2F;github.com&#x2F;jlongster&#x2F;absurd-sql</a>
tarasglekover 2 years ago
I wanted to use it in a chrome extension worker, but sync version of OPFS isn&#x27;t available in that context. Hope this gets fixed.
justincliftover 2 years ago
Interesting. Looks like the data persisted to disk should be available for opening via traditional SQLite GUI tools too (eg sqlitebrowser.org), though Chrome&#x2F;Chromium would probably need to be not running at the same time for safety.
Existenceblinksover 2 years ago
The sqlite.wasm is 683kB and the sqlite.js is 300kB. So is it supposed to be used in PWA context where these files are cached? Why no one is talking about CAP here. Is it real-production-ready?
评论 #34355284 未加载
raszover 2 years ago
we could call it WebSQL
systemsover 2 years ago
what is exactly the use case for this?
评论 #34354238 未加载
评论 #34354203 未加载
评论 #34356495 未加载
评论 #34355783 未加载
评论 #34355428 未加载
评论 #34354556 未加载
评论 #34355728 未加载
评论 #34354337 未加载
mgover 2 years ago
Let&#x27;s hope Firefox starts to support the File System Access API soon.<p>For me, it is the last missing piece to make web apps as comfortable as native apps.<p>I use a lot of web apps I fine-tuned exactly to my liking. I do all my writing in this web app for example: <a href="https:&#x2F;&#x2F;www.gibney.org&#x2F;writer" rel="nofollow">https:&#x2F;&#x2F;www.gibney.org&#x2F;writer</a> - I hit F11 and boom! I am in distraction free writing heaven :)<p>If Firefox would support the File System Access API, it would be much more comfortable to load and save my writings.
评论 #34355777 未加载
评论 #34356224 未加载
评论 #34359768 未加载
yyykover 2 years ago
The Web SQL standard was deprecated (by Mozilla) on the grounds of a single implementation.<p>The result today: A single SQL implementation with no standard (beyond SQLite) and therefore no easy way for anyone to create a compatible alternate implementation.
评论 #34355255 未加载
评论 #34355133 未加载
评论 #34355546 未加载
评论 #34355241 未加载
评论 #34355240 未加载
评论 #34359812 未加载
pfoofover 2 years ago
Cybersec is like &quot;here we go again&quot;
评论 #34359946 未加载
helfover 2 years ago
Yay. More ways for people to force webapps upon us.<p>I miss when the web was essentially a document viewer.
评论 #34355534 未加载
评论 #34355967 未加载
评论 #34355339 未加载
评论 #34359823 未加载