WhatsApp links
import { createWhatsAppLink } from 'pakdatakit/whatsapp'
Turns a Pakistani mobile number into a WhatsApp click-to-chat link. It accepts local, international and short phone formats, and can add a message that opens pre-filled in the chat.
createWhatsAppLink() Valid
- Link
https://wa.me/923001234567?text=Is%20this%20still%20available%3F
Examples
Section titled “Examples”import { createWhatsAppLink } from 'pakdatakit';
createWhatsAppLink('0300 1234567');// → 'https://wa.me/923001234567'
createWhatsAppLink('+92 321 7654321', 'Is this still available?');// → 'https://wa.me/923217654321?text=Is%20this%20still%20available%3F'
createWhatsAppLink('042-35761234');// → nullfrom pakdatakit import create_whatsapp_link
create_whatsapp_link('0300 1234567')# → 'https://wa.me/923001234567'
create_whatsapp_link('+92 321 7654321', 'Is this still available?')# → 'https://wa.me/923217654321?text=Is%20this%20still%20available%3F'
create_whatsapp_link('042-35761234')# → Noneimport 'package:pakdatakit/pakdatakit.dart';
createWhatsAppLink('0300 1234567');// → 'https://wa.me/923001234567'
createWhatsAppLink('+92 321 7654321', 'Is this still available?');// → 'https://wa.me/923217654321?text=Is%20this%20still%20available%3F'
createWhatsAppLink('042-35761234');// → nullusing PakDataKit;
WhatsApp.CreateLink("0300 1234567");// → "https://wa.me/923001234567"
WhatsApp.CreateLink("+92 321 7654321", "Is this still available?");// → "https://wa.me/923217654321?text=Is%20this%20still%20available%3F"
WhatsApp.CreateLink("042-35761234");// → nulluse PakDataKit\WhatsApp;
WhatsApp::createLink('0300 1234567');// → 'https://wa.me/923001234567'
WhatsApp::createLink('+92 321 7654321', 'Is this still available?');// → 'https://wa.me/923217654321?text=Is%20this%20still%20available%3F'
WhatsApp::createLink('042-35761234');// → nullReference
Section titled “Reference”createWhatsAppLink()
Section titled “createWhatsAppLink()”function createWhatsAppLink(phone: string, message?: string): string | null;Parameters.
phone: a Pakistani mobile number in any supported format.message: optional pre-filled message. It is URL-encoded for you.
Returns a https://wa.me/… link, or null if the phone number is invalid. Without a message (or with an empty one) the link has no ?text= part.
Related: validatePhone(), getNetwork().
Related
Section titled “Related”- Phone: validate and format mobile numbers.
- Networks: the original operator of a mobile prefix.
- Quality: check a phone number given for a delivery.
- API reference