#2786·LiteDB

Change notifications (observables) and WebSocket/HTTP hosting of LiteDB databases

Author: JKamskerCreated Sep 12, 2026Updated Sep 28, 2026
Labelssuggestionpriority: P3from fork

LiteDB has no way to subscribe to data changes and no way to reach a database over HTTP or WebSocket. A 2020 proposal (#1519) sketched a companion library for both:

  • host databases inside an ASP.NET app (app.UseLiteDB("/litedb", …)) with per-user authorization hooks;
  • connect through ws:// connection strings, from .NET and from JavaScript;
  • subscribe to filtered observables that fire on changes.

Users asked for an alpha twice in 2020, and a separate request (#2068) asks for an automatic HTTP JSON API. None of this exists on dev (47268cb4).

Use cases

  • Real-time change feeds. Get notified when documents that match a filter change, similar to RethinkDB changefeeds, Cosmos DB, MongoDB change streams or Firebase (#1519). Commenters want this mostly as a core notification API that people can put their own transport on top of, for IoT and reactive apps.
  • Remote access from the host app. Serve a database from an existing web app, without a separate server process. Interceptors (OnInsert, OnQuery, …) would enforce per-user permissions and filters (#1519).
  • Browser/JavaScript clients running queries and subscriptions over WebSocket (#1519).
  • Rapid prototyping. Expose collections as an HTTP JSON API automatically (#2068).

Current workarounds

  • LiteDB.Realtime wraps the engine and notifies subscribers after a successful commit. It relies on the LiteDatabase(ILiteEngine engine, …) constructor (LiteDatabase.cs:96), added in v5.0.5 by 7c78b035 (#1488).
  • For remote access: host a singleton LiteDatabase behind your own ASP.NET Core API or SignalR hub, and use the framework's authentication and authorization.

Possible design

The proposal covers two separate pieces of work:

  1. Post-commit change notifications in the engine (core, small). Raise an event or observable after a transaction commits, never before, so rolled-back changes are not reported. The payload should be the affected collection and document ids, so large transactions don't need the documents buffered in memory. Subscribers can then re-read or filter. Points raised in #1519: dispatch must not block the committing thread, and fire-and-forget dispatch has ordering and error-handling costs. The design should settle both, e.g. with an IObservable<ChangeEvent> that supports a filter expression.
  2. An out-of-tree hosting package (WebSocket/HTTP, auth hooks, JSON API, JavaScript client). It would be built on (1) and on the existing ILiteEngine extension point. Commenters suggested SignalR plus ASP.NET Core auth instead of a custom protocol.

Only (1) needs changes in this repository. If the maintainers take this on, (1) and (2) should be tracked separately.

Related issues

This consolidates the following reports, which are closed as duplicates of this issue:

  • #1519 — original proposal: LiteDB hosted over WebSocket/HTTP with authorization hooks and observables; includes the discussion of LiteDB.Realtime
  • #2068 — suggestion to expose an automatic HTTP JSON API on top of a database

Also related (not duplicates): #1773 (server/client-server mode), #158 (notification on database update), #1161 (replication, which a change feed would support), #2016 (management/web admin tool), #1526 (ILiteEngine injection for engine wrappers).