Explain Codes LogoExplain Codes Logo

Web link to specific WhatsApp contact

html
whatsapp
url-encoding
privacy
Anton ShumikhinbyAnton Shumikhin·Aug 8, 2024
TLDR

Initiate a chat on WhatsApp by using https://wa.me/<number>, replacing <number> with the phone number in international format.

<a href="https://wa.me/12345678901">WhatsApp me!</a>

Ensure to input the full phone number, including the country code - leave out any zeroes, brackets, or dashes. This link, upon clicking, opens a direct chat with the assigned number on WhatsApp.

Pre-filled messages for immediate communication

To pre-populate a specific message upon initiating the chat, include a text parameter in the URL, carrying your URL-encoded message. Here is an example:

<a href="https://wa.me/12345678901?text=Hello%20there!">Drop a quick hello</a>

The message "Hello there!" will be pre-filled in the WhatsApp chat window. It's like a ninja doing your work, but without the black suit.

Bookmarklet: Efficient repetition

If you're prone to send messages to various numbers frequently, saving them as a bookmarklets can be a game-changer. Here's a JavaScript snippet you can bookmark:

javascript: (function(){ var number = prompt("Share your WhatsApp number with country code:"); //It won't be shared with anyone, pinky promise! var message = encodeURIComponent(prompt("Your secret message here:")); //This stays between you and your keyboard! window.open(`https://wa.me/${number}?text=${message}`, '_blank'); })();

Drag above link to your bookmarks bar, click when necessary, input contact number and message, and boom! Your default web browser opens WhatsApp with a pre-filled message, ready to send.

Sharing WhatsApp links means sharing a part of your identity. To prevent possible referrer leakage, be privacy-aware and use rel="noreferrer" in your <a> tag:

<a href="https://wa.me/12345678901" target="_blank" rel="noreferrer">Start safe chat on WhatsApp</a>

This opens up WhatsApp on a new window/tab and keeps your original page's URL sealed away from prying eyes. Because the internet never forgets.

Stay up to date

To maintain winning user experience across devices and browsers, it's essential to regularly check for updates in your WhatsApp application.

When sharing WhatsApp links, make sure they are user-friendly. A little contextual instruction can go a long way!

Alternate methods for the adventurous

You can use whatsapp://send to open links directly within the app, though it's crucial to have the app installed and properly set-up to handle this.

<a href="whatsapp://send?text=Hello%20there!&phone=12345678901">Message in-app</a>

URL encoding: Bridge the gap between humans and internet

Your messages need to be URL encoded to maintain the link structure. Converting spaces and special characters into a URL-readable format is all the magic you need here.