Ludovic Frank - Freelance developer

On mobile (iOS and Android), there's a native sharing screen. How do you use it with the web?

ionicons-v5-k Ludovic Frank Feb 2, 2021
78 reads Level:

Sharing resources is at the heart of the Internet, and social networking buttons can be found on all kinds of sites, making it easy to share content so that others can enjoy it. On Android, this has been possible for some time, but on IOS and macOS it's only been available since version 12.1 of Safari. This article will be very brief, showing how to use this API.

window.navigator.share

This is the name of the function for sharing via the native window of the operating system, iOS or Android.

As explained above, this function isn't available everywhere, so you can check browser compatibility at "Can i Use".

Using the function is very simple, just follow the code below.

Simply link this code to a button on your interface (React, VueJS or even JQuery ...) and you'll see your operating system's native sharing window appear.

ios native sharing

Conclusion

Very practical, this allows sharing via all the applications installed on the user's smartphone (applications that allow sharing, of course).