4

I was wondering if there are any possibilities to efficiently communicate and share data between devices using an offline progressive web app without being able to access the internet.

The first things that came into my mind are the Web Bluetooth API (is this even possible?) and generating QR codes (using something like QRCode.js).

Any ideas?

ˈvɔlə
  • 9,204
  • 10
  • 63
  • 89
  • What is your use-case? What are the data-types you want to share? And what exactly do you mean by "offline"? Do you mean "no internet connection" (but all interfaces would be available, like bluetooth/wifi)? – Sebastian G. Marinescu Jul 15 '20 at 16:42
  • @SebastianG.Marinescu The use-case is to share some serialized data. Like I said: Offline means "[...] without being able to access the internet". Bluetooth or WiFi is present on the devices, yes. – ˈvɔlə Jul 15 '20 at 17:04

3 Answers3

2

So yes, it is possible, like everything in software development. Here are my thoughts/ideas.

If your serialized data is very small or just a number, then you could also just use Barcodes, with for example https://github.com/lindell/JsBarcode and https://serratus.github.io/quaggaJS/.

If your serialized data needs to be more flexible or in a custom object and does not exceed 3 KB (or the limits mentioned here) than you best go with QR-codes. You would of course on the receiving part of the application need a reader like for example:

And if you have a lot of data or need real-time-communication between two clients (e. g. Video/File-Transfer/etc.), then currently (as far as I know) you would use WebRTC. For this case you might need a TURN-server in between to establish the direct socket-connection - in this case I advise to take a look at SnapDrop which does it like this.

Good luck and let us know what you ended up using!

Sebastian G. Marinescu
  • 2,374
  • 1
  • 22
  • 33
2

I am doing this (kinda) today! https://github.com/pion/offline-browser-communication. The only downside is one side needs to be a native client, but the demo above allows two people to connect in the same network. They just need to agree on their mDNS Names and DTLS certificate ahead of time.

This functionality could also easily be added to the browser, but it needs to be championed in spec bodies. WebRTC doesn't allow users to choose their mDNS Names yet. You could use the mDNS name of the host though and it would work :)

Interestingly enough you can also use mDNS to determine a hosts name, so maybe could be used in conjunction? I have a jsfiddle here

Sean DuBois
  • 3,972
  • 1
  • 11
  • 22
1

No, you can't communicate or share data between two devices in offline PWA mode. Web Bluetooth API is still under experiment. However, you might be able to generate QR offline but communication won't be possible offline.