Rask.SQLite.Browser 0.20.1-alpha.0.212

This is a prerelease version of Rask.SQLite.Browser.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Rask.SQLite.Browser --version 0.20.1-alpha.0.212
                    
NuGet\Install-Package Rask.SQLite.Browser -Version 0.20.1-alpha.0.212
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Rask.SQLite.Browser" Version="0.20.1-alpha.0.212" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Rask.SQLite.Browser" Version="0.20.1-alpha.0.212" />
                    
Directory.Packages.props
<PackageReference Include="Rask.SQLite.Browser" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Rask.SQLite.Browser --version 0.20.1-alpha.0.212
                    
#r "nuget: Rask.SQLite.Browser, 0.20.1-alpha.0.212"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Rask.SQLite.Browser@0.20.1-alpha.0.212
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Rask.SQLite.Browser&version=0.20.1-alpha.0.212&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Rask.SQLite.Browser&version=0.20.1-alpha.0.212&prerelease
                    
Install as a Cake Tool

Rask.SQLite.Browser

A real SQLite database inside a browser WebAssembly app — the same Microsoft.Data.Sqlite, and the same Entity Framework Core on top of it, that you would run on a server — persisted across reloads.

Why

A WASM app has no filesystem that survives a reload. SQLite still runs there: the native e_sqlite3 is linked into the app at publish, and the database file lives in the runtime's in-memory filesystem. What is missing is durability, and one owner. This package supplies both.

  • Restored before anything opens it. A hosted service reads the newest snapshot out of IndexedDB and writes the file during StartAsync, so a service registered after it finds a populated database rather than an empty one.
  • Written back on an interval and on page-hide, through SQLite's Online Backup API (Rask.SQLite.Snapshots) — never an unsafe file copy of a database someone might be writing to.
  • Owned by exactly one tab. Every tab has its own copy of the in-memory filesystem, so two of them would hold two divergent databases and the last to snapshot would silently overwrite the other. A Web Lock elects one owner; the others run unpersisted and say so.

Use

builder.Services.AddRaskBrowserSqlite("app");
builder.Services.AddDbContextFactory<AppDbContext>(o =>
    o.UseSqlite(BrowserSqlite.ConnectionString("app")));

// From here on, nothing is browser-specific:
builder.Services.AddRaskJobs<AppDbContext>();

Register it before anything that opens the database — registration order is start order.

builder.Services.AddRaskBrowserSqlite("app", o =>
{
    o.SnapshotInterval = TimeSpan.FromSeconds(10);  // the real durability window
    o.Retain = 2;                                   // each snapshot costs a full database in quota
});

What to know before you rely on it

  • Entity Framework Core requires PublishTrimmed=false. EF Core does not survive the trimmer in a browser build — it fails with a MissingMethodException on a generic instantiation the trimmer removed. Microsoft.Data.Sqlite on its own is reflection-free and trims fine.
  • The durability window is the snapshot interval, not the page-hide flush. The browser does not wait for a pagehide handler, so a force-closed or crashed tab loses whatever changed since the last tick.
  • Snapshots live in IndexedDB, which is evictable. The owning tab asks the browser to exempt the origin (navigator.storage.persist()) at startup; a refusal is logged and changes nothing else. Chromium decides on engagement without prompting, Firefox prompts — so an app that would rather choose its moment sets o.RequestPersistentStorage = false and calls IStorageEstimator.RequestPersistAsync() from a user-gesture handler instead.
  • Non-owner tabs are not read-only — they are separate. They get their own empty in-memory database and never persist, which looks like data loss unless you say otherwise. Inject BrowserSqliteOwnership and tell the user: await ownership.Resolved gives the answer, and ownership.IsOwner is null while the election is still running so a normal boot never flashes a banner. When the owner closes, await ownership.Available completes so you can offer a reload — reloading is what takes ownership, since a waiting tab already opened its own empty database and the file cannot be swapped under live connections. Proxying a non-owner's writes to the owner is not implemented.
  • Snapshots cost their full database size in the origin's storage quota, times Retain.
  • Add <NoWarn>$(NoWarn);WASM0001</NoWarn> if you build with warnings as errors: the SQLite native build reports two varargs functions (sqlite3_config, sqlite3_db_config) that WASM cannot call. Neither is reached on the normal open/query/update paths.
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-browser1.0 is compatible.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.20.1-alpha.0.228 33 9/4/2026
0.20.1-alpha.0.227 26 9/4/2026
0.20.1-alpha.0.226 32 9/4/2026
0.20.1-alpha.0.225 32 9/4/2026
0.20.1-alpha.0.224 37 9/4/2026
0.20.1-alpha.0.223 32 9/4/2026
0.20.1-alpha.0.221 32 9/4/2026
0.20.1-alpha.0.220 30 9/4/2026
0.20.1-alpha.0.217 31 9/4/2026
0.20.1-alpha.0.216 40 9/4/2026
0.20.1-alpha.0.215 36 9/3/2026
0.20.1-alpha.0.213 33 9/3/2026
0.20.1-alpha.0.212 32 9/3/2026
0.20.1-alpha.0.211 38 9/3/2026
0.20.1-alpha.0.210 36 9/3/2026
0.20.1-alpha.0.209 31 9/2/2026
0.20.1-alpha.0.208 28 9/2/2026
0.20.1-alpha.0.207 40 9/2/2026
0.20.1-alpha.0.206 34 9/2/2026
0.20.1-alpha.0.204 39 9/2/2026
Loading failed