Install in your project
npm i @whizzes/walink
yarn add @whizzes/walink
pnpm i @whizzes/walink
Theres two ways you can consume this package in your code. By either providing
a singleton-like WhatsAppLinkMaker
instance, or using the utility function:
makeWhatsAppLink
.
The WhatsAppLinkMaker
instance allows you to specify the phone number to
use once and then make multiple messages with a single instance.
import { WhatsAppLinkMaker } from '@whizzes/walink';
const waLink = new WhatsAppLinkMaker('+112312344321');
const productLink = 'https://example.com/products/1';
const link = waLink.make(
`Hello I would like to know more about this product: ${productLink}`,
);
If you need to use different phone numbers on every message, the makeWhatsAppLink
function will be useful instead.
import { makeWhatsAppLink } from '@whizzes/walink';
const phoneNumber = '+112312344321';
const productLink = 'https://example.com/products/1';
const message = `Hello I would like to know more about this product: ${productLink}`;
const link = makeWhatsAppLink(phoneNumber, message);
Licensed under the MIT License