db.todos — no code changes required when moving between native and web targets. The key difference is that the directory parameter becomes a logical browser database name rather than a filesystem path, and Cindel uses a SQLite/OPFS backend instead of MDBX, which is not available in browsers.
Required Dependencies
Add bothcindel and cindel_flutter_libs to your pubspec.yaml. The cindel_flutter_libs package bundles the Web worker, JavaScript glue, and Wasm runtime that Cindel needs to run in the browser. Your Dart code only imports package:cindel/cindel.dart, but the browser needs everything cindel_flutter_libs ships.
Browser Requirements
Cindel Web requires the following browser features to be available:- Workers — used to run the database engine off the main thread
- Wasm — the native Rust core is compiled to WebAssembly
- OPFS — the Origin Private File System is where Cindel stores database files
MDBX is not used in browsers. Do not configure MDBX as a backend for Web targets — use the default SQLite/OPFS path.
Opening a Web Database
Pass a logical name todirectory when calling Cindel.open. This name identifies the browser database; it is not a folder that appears on the user’s device.
In-Memory Databases for Tests
For unit tests or temporary work that should not persist between runs, useCindel.openInMemory:
Use stable, descriptive
directory names for your production database (e.g. myapp_production) and separate names for demos, previews, or tests (e.g. myapp_demo, myapp_test) so they never share browser storage.Supported APIs on Web
All of the following work the same on Web as they do on native:Example: Query with Sorting
Example: Collection Watcher
Backup on Web
UseCindelBackupCompression.none when exporting on Web. Gzip compression is not supported in the browser runtime.
Current Limitations
Keep the following restrictions in mind when targeting Web:- No MDBX backend — only SQLite/OPFS is available in browsers.
- Watcher delivery is single-tab only — this includes sync watchers. One tab cannot receive watcher events triggered by writes in another tab.
- No multi-tab coordination — if your app supports multiple tabs, design the UI so each tab can reload or re-open its local view independently.
- Browser storage quota and OPFS availability vary — quota limits and OPFS support depend on the browser, OS, and user settings.
Handling Storage Errors
If the browser blocks Workers, Wasm, or OPFS — for example in a private browsing session or when storage quota is exceeded —Cindel.open will throw a CindelOpenError.