Introducing Blazor Web Share
Blazor.WebShare is an open-source library that enables easy implementation of Web Share API in Blazor web applications. This API allows users to share content from your web app to other apps on their device, such as email, messaging, or social media.
Here’s an example of how to use Blazor.WebShare to share a text message:
@inject IWebShareService WebShareService
async Task Share()
await WebShareService.ShareAsync("Title", "Text", "https://www.google.com");
In this example, we use a simple component to create a button that triggers the Web Share API when clicked. The Text property sets the text of the share, and the Title property sets the title of the share dialog.
Since we rely on the WebShare API, the support is actually quite nice and even works on Safari iOS! To be honest my mind was blown when I saw this.
If you want to learn more about Blazor.WebShare or contribute to the project, check out the Open Source GitHub repository.