While building PromptPulse, I wanted users to download the client, start using it and keep chat history locally. On March 10 I first tried Node.jsâs built-in node:sqlite, only to get a module-unavailable error. With better-sqlite3 I then had to distribute a native dependency with Electron Forge. Looking for something easier to ship, I asked Cursor directly on March 13:1
is IndexedDB available for nodejs enviroment?
is leveldb binary or pure js
The question returned in June when I separated the React chat interface and developed Meowssenger. This time the UI had to run in a browser. Could localhost use IndexedDB? Would records survive closing the browser? How much data could it hold? On June 4 I explicitly requested switching storage to IndexedDB. A June 8 commit added MeowssengerDB and the chatHistory object store.23
My recollection that these searches related to Meowssenger was accurate, but similar questions had already arisen during PromptPulse. Together the projects taught me to start a local database decision by asking which runtime owns the data, then compare library APIs.
âLocal,â âbuilt-inâ and âpure JavaScriptâ are three different questions
My interest in a pure JavaScript database came mainly from wanting to reduce build and packaging work for native dependencies. Distinguish these requirements:
| Requirement | Real concern | Example |
|---|---|---|
| Local storage without an independent database service | Must the user install and start a service? | SQLite can read and write a local database file directly. |
| Built into the runtime | Does the browser or specific runtime version already provide it? | Browser IndexedDB, or node:sqlite in some Node.js versions. |
| No additional native extension to ship | Does an npm dependency require binaries matching platform, architecture and runtime? | A JSON file implementation can depend only on Nodeâs filesystem API. |
| Shared JavaScript interface | Can business code be reused across environments? | level can use different storage implementations in Node.js and a browser. |
These requirements are not equivalent. SQLite is embedded, but better-sqlite3 includes a native extension. Browsers provide IndexedDB without implying that its engine is written in pure JavaScript. A library usable in two environments does not automatically share data between them.456
Browser: localStorage for settings, IndexedDB for chat history
localStorage works well for small settings such as theme and sidebar state. It stores string key/value pairs with synchronous reads and writes. Complex objects typically require explicit JSON serialization. With growing conversations and messages, repeatedly reading, changing and writing all history as one large string makes even a small update touch the entire dataset.7
IndexedDB provides object stores, keys, indexes and transactions, with asynchronous reads and writes. It can store objects supported by structured cloning, including files and Blobs. One phrase from MDN matters here:8
IndexedDB is a transactional database system
It is therefore more than a larger localStorage. For chat history, update a conversation by ID and use an index for a particular lookup without rewriting all history. Transactions allow related operations to commit together. Design object stores and indexes around the queries you need. IndexedDB does not automatically provide SQL joins.
Meowssengerâs implementation was straightforward: create chatHistory keyed by id, save conversations with put, and restore history in a read-only transaction. This solved browser-side persistence without deploying a database server just for chat.3
During the two days I worked on Meowssengerâs attachment picker, I also checked what file types ChatGPT accepted, how large one file could be and whether it could open ZIP archives directly.

Local example screenshot before sending, recreated in November 2026. After selecting three images you can preview or remove them individually. Thumbnails are cropped from Ubuntu wallpapers by OrbiteLambda, Tibor MokĂĄnszki and Hajime Mizuno, left to right. The image retains the CC BY-SA 4.0 license.
How do you show attached pictures after reopening a conversation? One option is to store each image as a Blob, a browser object representing binary data. In an IndexedDB read/write transaction write the image keyed by attachment ID, retaining only that ID in the message. Next time read the Blob by key and use URL.createObjectURL() to generate a temporary URL for the image element.910
Choose the stored type according to what you need on retrieval. To display the original filename from a file picker in a chat bubble, save the File, which carries its name. For an image to preview, a Blob suffices. Read an ArrayBuffer (byte buffer) when you need specific bytes, such as the file header.10
It works on localhost and normally survives closing the browser, within limits
My localhost question concerned dependable retention in development. In ordinary browsing mode, a localhost page can use IndexedDB and closing the browser does not normally clear committed data. Browser storage rules still apply:11
- The address determines ownership.
http://localhost:5173,http://127.0.0.1:5173andhttp://localhost:5174are distinct origins. Seeing an empty database after changing address does not necessarily mean the original was deleted. - Capacity depends on the browser and device. Use
navigator.storage.estimate()for estimated usage and quota, and still handle insufficient space when writing. - Persistence is not backup. Default storage may be subject to eviction.
navigator.storage.persist()requests persistent storage, but the browser decides and users can still delete site data. Important conversations need export or another backup.
This explains why âon my machineâ is insufficiently precise. The browser manages IndexedDB data. Users do not manage it directly as they would a JSON file.
Node.js: JSON files and SQLite serve different scales
The browserâs IndexedDB API is not provided by Node.js by default. Even with a compatibility layer, check whether the underlying data reaches disk, whether native dependencies are added, and whether the implementation suits production. React on the frontend does not allow code running in a Node service to use browser storage APIs directly.
JSON files: reduce dependencies first
One route PromptPulse actually used was writing chat history directly to JSON. On March 13 I asked Cursor to replace database operations with plain JSON files, preserve input and output and add no dependencies. By the March 17 commit, json_db_utils wrote conversations to a chat_histories folder under Electronâs user data directory.112
For small data, one writer and simple queries, this is easy to understand, export and inspect. File writes do not automatically provide database transactions. Two calls reading old contents and writing back separately can overwrite each other. Updating multiple files for one conversation also requires handling partial success.
A JSON file library can reduce some groundwork. For example, lowdb v7.0.1 lists âPlain JavaScriptâ and âSafe atomic writes.â Its documentation also notes that its JSON file implementation serializes and rewrites the entire dataset on write and does not support Node cluster mode. Atomic file writes solve one class of integrity problem without establishing multiprocess transactions. lowdb is a comparison here, not a dependency I adopted at the time.13
SQLite: when querying and consistency justify packaging work
For multi-condition message queries, usage statistics, related data or coordinated updates, SQLiteâs relational model and transactions have more value. Users need no separate database service, although Node.js integration still requires a binding or built-in runtime API.5
I initially tried the built-in interface. On the evening of March 10, I used this import in PromptPulse/desktop/express_server/index.js and created an in-memory database with DatabaseSync(':memory:'). I was still discussing auto-incrementing primary keys with Cursor:1
const { DatabaseSync } = require('node:sqlite');
Then I attached this terminal error to the conversation:
ERR_UNKNOWN_BUILTIN_MODULE]: No such built-in module: node:sqlite
This was around 18:31 on March 10. Cursor suggested sqlite3 or better-sqlite3, but its explanation that Node.js had no such built-in module was too broad. node:sqlite was introduced in Node.js v22.5.0. The v22.14.0 docs still marked it âStability: 1.1 - Active development.â The error shows my runtime did not provide it, without establishing that all Node.js versions lacked support.15
Built-in interfaces also have runtime requirements. Check the actual Node/Electron version that launches the app and whether its module exists, not a separate Node installed on the system. The terminal excerpt lacks complete runtime details, so it cannot establish precisely which version or build condition caused the error.
Using better-sqlite3 brought a different issue. Successfully installing the JavaScript package does not establish that its native module works with the target Electron. Check the runtime ABI, operating system, CPU architecture and inclusion of native files before delivery. Issue #538, which I read, discusses cross-platform builds for Electron and better-sqlite3.414
Its troubleshooting documentation specifically notes:15
If you're using an app.asar bundle, be sure all native libraries are "unpacked".
Unpacking addresses file location. Rebuilding addresses binary compatibility. More of the packaging experience appears in the PromptPulse development notes.
Does querying SQLite with Prisma still require installing sqlite3?
I asked a packaging question: âis prisma a native module for nodeâ. To read chats from a SQLite file, direct better-sqlite3 loads its packaged native extension. With Prisma, application code can query models through a generated JavaScript client, and Prisma translates the query into SQL. Such tools mapping code objects to database tables are object-relational mappers (ORMs). Who actually opens the SQLite file? With PostgreSQL, who connects to the server?
Consider Prisma 6.4.1, already released by March 2025. Under its default Node.js configuration, Prisma Client passes queries to a Rust query engine with built-in database drivers. The engine opens SQLite files without requiring the app to install an npm package called sqlite3 or better-sqlite3. Likewise the built-in drivers for PostgreSQL and SQL Server need no extra pg or mssql package.16
This led to my follow-up: if a Rust engine handles queries, does the package contain a .node file?
đ What is a
.nodefile? It is a native extension loadable by Node.js. Its functions have been compiled to machine code, instructions the target processor can execute directly. For example, the first timebetter-sqlite3opens a database, its JavaScript loadsbetter_sqlite3.nodeinto the current process and calls extension functions to open the SQLite file holding chat history.17
Prisma 6.4.1âs default configuration does include one. Its default engine type is library. One Windows filename is query_engine-windows.dll.node. Node.js loads this Rust library into its process via Node-API, the interface between native code and JavaScript, making it a Node native extension. Setting engineType = "binary" instead has the client start a separate engine process.18
Both forms require shipping a matching engine file for the target. Prismaâs prebuilt artifacts generally suffice. For example, when developing on macOS and also shipping Windows x64, set binaryTargets = ["native", "windows"] in the prisma-client-js generator and run prisma generate. native means the machine running generation, while windows fetches the Windows engine too. Include that file in the Windows installer. Linux targets must match processor architecture, system C library and OpenSSL version.19
Prisma 7 subsequently changed the answer. Its default generated client no longer ships the Rust query engine above. For a direct local SQLite connection, install @prisma/adapter-better-sqlite3. It forwards Prisma calls to better-sqlite3, already a dependency of adapter version 7.0.0 and installed by npm. Applications querying exclusively via Prisma need not separately declare better-sqlite3 or install the distinct sqlite3 package. The desktop installer must still ship a target-compatible native extension, now supplied by the SQLite driver. Direct PostgreSQL uses @prisma/adapter-pg.20
Where to put the SQLite file
Once the database ran, I needed a place for the file. Development rebuilds and closing and reopening the client should preserve the same data. I researched SQLite locations for production Electron and put it under userData in a databases directory.
Around 19:32 on March 13 I asked Cursor to replace the in-memory database with a file in the user data directory and print the path so I could confirm creation. Around 19:59 I asked:21
will the database here be destroyed between dev builds
In other words, would rebuilding during development remove the existing database? A Stack Overflow question I opened described placing SQLite beside Main.js during development, then failing to find the file after packaging. An answer suggested the applicationâs user data directory:22
const dbPath = path.join(app.getPath("userData"), "sample.db")
I adopted that approach in commit 0029667 at 19:51 that day. It created a databases subdirectory, saved prompt_pulse_data.db, printed the actual path and opened the file by path in place of the in-memory database. This change reached the code.23
Distinguish the application code location from user data. Electron supplies the userData directory, with the default depending on platform and application name. Storing the database there separates it from source and build outputs. If development and release builds use different application names or explicitly change the path, still verify they open the same database.24
An Open WebUI user likewise wanted to locate the database after installing with pipx on a Mac. A reply gave /app/backend/data/webui.db, the path inside a Docker container. Searching for webui.db eventually located the file in the askerâs pipx virtual environment. The same filename can be in a different directory under a different installation method, another reason to display the actual path.25
LevelDB: a JavaScript API does not imply a pure JavaScript engine
âis leveldb binary or pure jsâ illustrates that I cared about binary distribution as well as API convenience.
For example, level v8.0.1 offers a similar interface across environments with different implementations: Node.js uses LevelDB-based classic-level, browsers use IndexedDB-based browser-level. Choosing level neither eliminates native dependencies on Node nor lets a browser open the same copied database file.626
It suits key-based reads, writes and ordered iteration. Compared with a relational database, you must organize keys and additional query conditions yourself. A shared API reduces differences in business code while retaining underlying distinctions, such as different iterator snapshot guarantees in these implementations. For cross-platform reuse, identify the common capabilities the application actually relies on.6
RxDB: look through to the storage adapter
I also read RxDBâs Node.js database introduction. It offers document operations, reactive queries and synchronization facilities above a storage layer. For a chat UI, updating as data changes and eventually syncing multiple devices are potentially useful directions.27
Adopting this framework does not eliminate the underlying choice. Native dependencies, data location and deployment still depend on the specific storage implementation. The label âJavaScript databaseâ alone cannot establish native-free operation. I researched RxDB but did not adopt it in these PromptPulse or Meowssenger implementations.
Electron: decide who owns the data first
Electron includes a Node.js main process and renderer processes that display web content, so SQLite, file storage and IndexedDB may all appear in one app. Decide which side owns reads and writes before choosing storage.28
For a chat UI that must also run independently in browsers, IndexedDB is a natural place for UI persistence. Meowssenger needed that. If a local service, multiple windows or other tasks need coordinated access to history, consider Node-managed storage exposed through a clear interface.
I would narrow shared operations to application interfaces such as listConversations, loadConversation, saveConversation and deleteConversation, then supply browser and desktop implementations. This is a design inferred from the two experiences. Neither project had already completed such a unified layer. Matching interfaces do not synchronize data automatically. Import, export and sync still require design.
The actual project decisions were not mutually exclusive. PromptPulse retained a SQLite module for model interaction data while saving chat history to JSON. Meowssenger stored browser chat history in IndexedDB.312 The former needed to account for installer dependencies and local files, the latter for independent browser use and recovery after refresh. Those constraints make decisions easier than starting with a search for the best database in every environment.
Original search terms
I retained these searches covering pure JavaScript options, the Node/browser API boundary and how LevelDB is implemented:29
is there a pure javascript database that can run in nodejsIndexedDB for nodejs enviromentdatabase in broswerleveldb js
References
Footnotes
-
Cai, B. (2025, March 10â13). SQLite Auto-Increment Index Implementation; IndexedDB Availability in Node.js; Integrating Electron with better-sqlite3; JSON File Storage Implementation in JavaScript [unpublished local development conversation with Cursor]. The March 10 editor context shows the import, and the terminal selection attached by the user shows the error. The subsequent reply began at 18:31:24 Beijing time. With no separate timestamps for the user message and terminal output, the text gives approximately 18:31. IndexedDB, LevelDB, packaging and the JSON alternative appear in the March 13 conversation. â© â©2 â©3 â©4
-
Cai, B. (2025, June 3â4). Add hide button for history bar; Use indexedDB instead of local storage [unpublished local development conversation with Cursor on localhost, persistence, quotas and switching to IndexedDB]. â©
-
Cai, B. [S2thend]. (2025, June 8). Meowssenger: IndexedDB chat history implementation [source, commit 826dc29, history lookup and save functions in ChatView.jsx]. GitHub. https://github.com/S2thend/Meowssenger/blob/826dc29a00cca818831b8135f23a6a5aa905a20a/webui/src/views/ChatView.jsx . â© â©2 â©3
-
Electron contributors. (n.d.). Native Node Modules (âInstalling modules and rebuilding for Electronâ). Electron. https://www.electronjs.org/docs/latest/tutorial/using-native-node-modules . Verified November 17, 2026. â© â©2
-
Node.js contributors. (n.d.). SQLite [Node.js v22.14.0 documentation, module introduction and DatabaseSync]. GitHub. https://github.com/nodejs/node/blob/v22.14.0/doc/api/sqlite.md . Verified November 17, 2026. â© â©2 â©3
-
Level contributors. (n.d.). level [v8.0.1 README, introduction and Iterator]. GitHub. https://github.com/Level/level/blob/v8.0.1/README.md . Verified November 17, 2026. â© â©2 â©3
-
MDN contributors. (n.d.). Web Storage API (âConcepts and usageâ). MDN Web Docs. https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API . Verified November 17, 2026. â©
-
MDN contributors. (2025, April 3). IndexedDB API. MDN Web Docs. Quotation in opening paragraph of âKey concepts and usageâ; for asynchronous I/O see âSynchronous and asynchronousâ on the same page. â©
-
MDN contributors. (2026, September 11). Using IndexedDB. MDN Web Docs. See the read/write transaction and keyed retrieval examples in âAdding, retrieving, and removing data.â â©
-
Ankit_Shah55. (2015, August 4). IndexedDB: Store file as File or Blob or ArrayBuffer. What is the best option?. Stack Overflow. See the file-picker example in the question and gafiâs August 13, 2015 answer on generating a display URL after reading a Blob. â© â©2
-
Storage allocation and eviction vary by browser. See MDN contributors. (2025, April 3). IndexedDB API. MDN Web Docs, âStorage limits and eviction criteriaâ. For detailed rules see MDN contributors. (2026, January 5). Storage quotas and eviction criteria (âHow do browsers separate data from different websites?â; âDoes browser-stored data persist?â; âHow to check the available space?â). MDN Web Docs. https://developer.mozilla.org/en-US/docs/Web/API/Storage_API/Storage_quotas_and_eviction_criteria . Verified November 17, 2026. â©
-
Cai, B. [S2thend]. (2025, March 17). PromptPulse: JSON chat history and SQLite utilities [source, commit 925a9b7]. GitHub. JSON: https://github.com/S2thend/PromptPulse/blob/925a9b70efe6b9f84812e9cb8fa4a038a9b37395/desktop/express_server/json_db_utils/index.js ; SQLite: https://github.com/S2thend/PromptPulse/blob/925a9b70efe6b9f84812e9cb8fa4a038a9b37395/desktop/express_server/sqlite_utils/index.js . â© â©2
-
typicode. (n.d.). lowdb [v7.0.1 README, âFeaturesâ and âLimitsâ]. GitHub. https://github.com/typicode/lowdb/blob/v7.0.1/README.md . Verified November 17, 2026. â©
-
patarapolw. (2021, January 15). How to cross compile better-sqlite3 with electron? [Issue #538; see also pietersartainâs April 26, 2021 build experience]. GitHub. https://github.com/WiseLibs/better-sqlite3/issues/538 . Related reply: https://github.com/WiseLibs/better-sqlite3/issues/538#issuecomment-826810981 . Access date: June 12, 2025. â©
-
better-sqlite3 contributors. (n.d.). Troubleshooting installation [v11.8.1, âElectron,â ASAR note]. GitHub. https://github.com/WiseLibs/better-sqlite3/blob/v11.8.1/docs/troubleshooting.md . Verified November 17, 2026. â©
-
Prisma. (n.d.). Database drivers (Prisma ORM v6). Prisma Documentation. Default built-in drivers. â©
-
Node.js contributors. (n.d.). C++ addons (Node.js v22.14.0). Node.js Documentation. Loading addons using require(). better-sqlite3 contributors. (n.d.). lib/database.js (v11.8.1) [source code]. GitHub. Loading the native extension and opening the database. â©
-
Prisma. (2025, February 20). Prisma ORM 6.4.1 [source code]. GitHub. Default engine type and Node-API library filenames by platform. For the two loading modes see Prisma. (n.d.). Engines. Prisma Documentation. The query engine at runtime. â©
-
Prisma. (n.d.). Deploy to a different OS and Prisma Schema API (Prisma ORM v6). Prisma Documentation. Cross-OS deployment and
binaryTargetsplatform table. â© -
Prisma. (n.d.). Upgrade to v7. Prisma Documentation. Driver adapters. Prisma. (2025). @prisma/adapter-better-sqlite3 (7.0.0) [package manifest]. GitHub. Runtime dependencies. â©
-
Cai, B. (2025, March 13). Saving SQLite Database to User's Data Folder [unpublished local development conversation with Cursor]. The replies following the questions about saving in the user directory and rebuilding began at 19:32:13 and 19:59:02 Beijing time respectively. The questions have no separate timestamps. â©
-
HardRock. (2021, February 19). Where to store SQLITE db file in electron production mode? [question]; Makwana, H. (2021, February 28). [answer, first paragraph and code line]. Stack Overflow. https://stackoverflow.com/questions/66284654/where-to-store-sqlite-db-file-in-electron-production-mode . Code quoted from the answer. Access date: June 12, 2025. â©
-
Cai, B. [S2thend]. (2025, March 13). feat: :wrench: add feature save sqlite database to userdata folder [commit 0029667, saveResultsToDatabase and loadDataFromDatabase in desktop/express_server/index.js]. GitHub. https://github.com/S2thend/PromptPulse/commit/0029667ba86ffe0c6f182b1481b245097e8c0d4d . Commit time 19:51:32 Beijing time. â©
-
Electron contributors. (n.d.). app (âapp.getPath(name)â, userData; âapp.setPath(name, path)â; âapp.getName()â). Electron. https://www.electronjs.org/docs/latest/api/app#appgetpathname . Verified November 17, 2026. â©
-
dytibamsen. (2025, January 16). Where are chats and other data stored?. Reddit, r/OpenWebUI. See the local path found by the asker and Rriven21âs explanation of the Docker path. â©
-
Level contributors. (n.d.). classic-level [v1.4.1 README, introduction and Supported Platforms]. GitHub. https://github.com/Level/classic-level/blob/v1.4.1/README.md ; browser-level [v1.0.1 README, introduction]. https://github.com/Level/browser-level/blob/v1.0.1/README.md . Verified November 17, 2026. â©
-
RxDB contributors. (n.d.). RxDB â The Real-Time Database for Node.js. RxDB. https://rxdb.info/nodejs-database.html . Access date: June 12, 2025. â©
-
Electron contributors. (n.d.). Process Model (âThe main processâ; âThe renderer processâ). Electron. https://www.electronjs.org/docs/latest/tutorial/process-model . Verified November 17, 2026. â©
-
Google. (n.d.). Searches for local database selection [search terms retained by the author]. Pure JavaScript database in Node.js; IndexedDB for Node.js; Database in browser; LevelDB JS. Access date: June 12, 2025. â©