Google Releases Web Share API for Website Developers

Google Releases Web Share API for Website Developers

We may earn a commission for purchases made using our links.

Android has had an API for sharing content between applications for a while now, but there hasn’t been a similar solution for the web. You generally see share buttons for individual applications scattered across the bottom of an article as each website has their own way to share content. This process is easier for Android application developers since there is a standard and that’s what Google wants to bring to the web.

Matt Giuca, a developer who works on the Chrome team, has been working on what Google is calling the Web Share API. This simple API allows developers to trigger the native sharing capabilities of the host platform (which will be Android in this case). The idea is simple, if you wanted to save the URL of a website in an application like Google Keep, you would simply need to tap the Share button that appears on the website and then it will open up the Share dialog box for Android. Here’s a brief demo that Google has provided. . .

Google has just announced what they are calling an Origin Trial of the API, and it is currently working in the beta version of Chrome 55 (which was released in October). This Origin Trial means that the Web Share API will only be available on websites who opt-in to the test run. Web developers can find more information on how to participate in this trial run over on this GitHub page.

In order to implement the Web Share API in your website, you will need to have a few things setup ahead of time. For example, only websites that are hosted in a secure context (which generally means HTTPS) will be able to use this Web Share API. You will also need to supply either the Text or the URL, but both is nice, the API can only be triggered via a user gesture, and the values you pass into the API must be strings.

Source: Google