Explain Codes LogoExplain Codes Logo

Sharing link on WhatsApp from mobile website (not application) for Android

web-development
responsive-design
best-practices
mobile-development
Nikita BarsukovbyNikita Barsukov·Jan 4, 2025
TLDR

Create a WhatsApp share link like this:

<a href="https://wa.me/?text=encodedText">Share</a>

Here, you need to replace encodedText with your URL-encoded message. This triggers the WhatsApp contact selector upon clicking the link.

An example could be:

<a href="https://wa.me/?text=Awesome%20site%3A%20https%3A//example.com">Share on WhatsApp</a>

This triggers a prompt with a pre-filled message in WhatsApp.

Catering to different devices

When sharing via WhatsApp, it's crucial to optimally serve users across different devices. Implement UserAgent detection to customize the sharing experience for Android and iOS users.

Rely on Android Intents to create a more native sharing experience:

<!-- Who needs smoke signals when you have Intents on Android --> <a href="intent://send/YourShareTextHere#Intent;scheme=smsto;package=com.whatsapp;action=android.intent.action.SENDTO;end"> Share via WhatsApp </a>

Regularly test on different devices and browsers. Tools like BrowserStack are your best bet for ensuring a seamless sharing user experience.

Keep track of the updates in share URLs. Check resources like social-share-urls on GitHub.

Boosting visibility

To allure users into sharing, make the WhatsApp share link conspicuous on your page.

Appealing design

  • Utilize vibrant buttons or catchy icons.
  • Position the share link where it's most relevant.

Persuasive messaging

  • Use phrases like "Spread the info" or "Help a friend."
  • Display the benefits or reasons for sharing, e.g., "Share this deal with your WhatsApp buddies!"

Addressing common scenarios

Preempt common sharing scenarios:

Localization:

  • Provide localized links.

Fallbacks:

  • Have fallbacks like email or social media sharing if the user doesn't have WhatsApp.

Privacy:

  • Be transparent about the data you track when one shares your content.