Offline DB (SQLite) with Blazor WASM

Prathamesh Shende 376 Reputation points
2021-12-31T15:18:47.843+00:00

I have seen so many web app that supports offline. Like IF internet is not available but still use can post and update data into webapp
and then move to online database sql after webapp goes online.

Can we implement this Blazor WASM connect sqlite or with IndexedDB and post offline changes to online database?

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,386 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,700 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Michael Washington 911 Reputation points MVP
    2021-12-31T15:24:49.767+00:00

    This example does just that:
    CarChecker - a Blazor sample app

    There is a video where he explains how it works on Channel 9: Modern Web UI with Blazor WebAssembly


  2. Bruce (SqlWork.com) 55,601 Reputation points
    2021-12-31T16:52:28.117+00:00

    The sample blazor app uses local storage via JavaScript interop for offline support. But it requires the app to be running to do the upload.

    A more common approach is to use a service worker that does the upload in the background, so the app does not need to be running. A service worker can also cache requests, so you can keep all the logic in one place. As blazor httpclient uses JavaScript interop to fetch data, it works perfectly with service workers.