10

I have a Blazor WebAssembly ASP.NET Core hosted - PWA application and want to run it offline. The database is currently built with SQLite and EF-Core. Is it possible to add offline functionality? I have read about IndexedDB but don't actually know how to implement that into the project (client-side). Or is there any NuGet Package for this support?

The functionality I want to bring into the project is - tracking local changes and fetching them to the DB when its online again.

2
  • Ah, hosted is not webassembly, you know. And your database (sqlLite) is not exactly webassembly either. Also sqllite would not really handle syncing- that requires programming.Easy answer thus is NO. Hosted model runs on the server, not using WebAssembly.
    – TomTom
    Jul 5, 2020 at 19:33
  • 1
    @TomTom It is WebAssembly Client-Side but in addition with the Server-Side. So at runtime the server is building up the client and they can communicate via Http Requests. The "offline" DB should be in a way in the client project and fetch via Http request to the server DB. The only problem is I don't know how to do that ^^..
    – brstkr
    Jul 5, 2020 at 20:34

4 Answers 4

6

I've created a library that provides bi-directional offline sync for mobile clients that should do the job: https://github.com/stefffdev/NubeSync

Especially handling conflict resolution when multiple clients did change a record can become tricky, so you could use that as a starting point.

I plan to create a blazor wasm offline sample and blog about it soon.

2
  • Hi, I'm looking at the sample for Blazor WASM and it's confusing me. It seems to call the server via http client directly from your Razor pages. Does this provide a persistent cache for when an app is offline for multiple days (allowing user to continue working) then syncs once online? Sep 13, 2021 at 11:27
  • Hi, you are right, in the provided sample I'm just calling REST calls without any offline capability. Currently I am not working on a Blazor offline client since we are not developing Blazor apps right now. A few infos on that you can find here github.com/stefffdev/NubeSync/issues/22
    – stefffdev
    Sep 15, 2021 at 4:41
2

You can try this package. This is a Blazor library to work with IndexedDB DOM API

https://github.com/amuste/DnetIndexedDb

1

check This example, uses javascript to store locally in the browser

1

I'm using event sourcing to solve this problem. It deals well with syncing occasionally connected clients as described here. It means dropping entity framework and probably rearchitecting your entire persitance tech stack, so it is far from ideal. But if you plan on building a large complicated system, this is the way to go.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.