0.1.0 • Published 1 year ago

@whizzes/walink v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Build Tests Lint Publish Version Downloads

Getting Started

Install in your project

npm i @whizzes/walink

yarn add @whizzes/walink

pnpm i @whizzes/walink

Usage

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.

Using WhatsAppLinkMaker instance

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}`,
);

Using makeWhatsAppLink utility function

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);

License

Licensed under the MIT License

0.1.0

1 year ago