Benjamin Vertonghen
2 min readSep 12, 2023

Introducing Blazor Web Share

Share API on iOS

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.

Implementing the Web Share API in Blazor can be challenging since we rely on JavaScript. That’s where Blazor.WebShare comes in. This library simplifies the implementation of the Web Share API by providing a service that you can easily integrate into your Blazor web application.

Here’s an example of how to use Blazor.WebShare to share a text message:

@using Append.Blazor.WebShare
@inject IWebShareService WebShareService

<button @onclick="@Share">Share</button>

@code{ra
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.

Support

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.

Benjamin Vertonghen
Benjamin Vertonghen

No responses yet