DEV Community

Cover image for How to add the Whatsapp share button in Web Apps?
Manideep Pullalachervu
Manideep Pullalachervu

Posted on

How to add the Whatsapp share button in Web Apps?

We see many web applications having this WhatsApp share button to share the content. Have you wondered how we can have it in our next web app? You know, it's very easy, as easy as using an Html element.

The only thing you need is the below universal links.

Example: https://wa.me/<number> 
Example: https://wa.me/<number>?text=<urlencodedtext>
Enter fullscreen mode Exit fullscreen mode

Breakdown of above links:

  • The <number> is a full phone number in international format. Omit any brackets, dashes, plus signs, and leading zeros when adding the phone number in international format.
Examples:

Use: https://wa.me/919999999999

Don't use: https://wa.me/+91-9999999999
Enter fullscreen mode Exit fullscreen mode
  • The <urlencodedtext> is a URL-encoded pre-filled message, that will automatically appear in the text field of a chat. URL encoding? converts characters into a format that can be transmitted over the Internet. HTML URL Encoding Reference
Example: 

https://wa.me/919999999999?text=I'm%20interested%20in%20your%20car%20for%20sale
Enter fullscreen mode Exit fullscreen mode

How many ways we can use the above links:

  • We can create a link with just a pre-filled message, use https://wa.me/?text=urlencodedtext
  • We can create a link with no pre-filled message, use https://wa.me/<number>

Finally, how to use the link?

Example: 

<a href="https://wa.me/919999999999text=I'm%20interested%20in%20your%20car%20for%20sale">Share</a>
Enter fullscreen mode Exit fullscreen mode

When a user clicks on the above link it opens the WhatsApp application installed on users device either it be a phone or desktop.

To learn more please visit: How to link to WhatsApp from a different app

Top comments (0)