By Emmanuel Aina

Building a share feature can be overwhelming. Taking into account the stress of reading through different platforms (Like Twitter, Facebook or Instagram), developer documentation and app registering, uugh!.

Luckily, some libraries make it easier to implement these features.

However, there is a possibility that you’re someone like me that cares about every extra kb added to a load of whatever I build.

This article would entail my understanding of how best to effect a native share feature on the web. Similar to what the image below communicates.

SmartSelectImage_2019-06-04-09-47-12.jpeg

I would be using the Web Share API to perform this. The API is a promise-based and single object API. Its implementation is as simple as:

if (navigator.share) {
	navigator.share({
		title: ‘Native share on the Web’,
		text: Native share on the Web — PillsOfCodes',
		url: '[<https://pillsof.codes/native-share-on-the-web>](<https://pillsof.codes/native-share-on-the-web>)',
	})
	.then(() => console.log('Successful share'))
	.catch((error) => console.log('Error sharing', error));
}

Breaking down the code above, we understand that: