Skip to content

Instantly share code, notes, and snippets.

@anmolsukki
Last active March 31, 2022 09:25
Show Gist options
  • Save anmolsukki/c2a9cfebd80a613fb1b2efde5682f15e to your computer and use it in GitHub Desktop.
Save anmolsukki/c2a9cfebd80a613fb1b2efde5682f15e to your computer and use it in GitHub Desktop.
Share Multiline Message on WhatsApp
import React from 'react';
const WhatsAppShare = () => {
const whatsappMessage =
'Dear Customer,' +
'\r\n\r\n' +
'Thanks for shopping at Gyftr. Your Gift Code details' +
'\r\n\r\n' +
'Brand: Amazon' +
'\r\n' +
'Voucher Code: ZT32-HRGSF5-T6RN' +
'\r\n' +
'Voucher PIN: -' +
'\r\n' +
'Value: 250' +
'\r\n' +
'Expiry Date: 14 Jun 2023' +
'\r\n\r\n' +
'Visit https://www.gyftr.com/instantvouchers/ for more details.';
return (
<div>
<a className="d-md-none" href={`whatsapp://send?text=${encodeURIComponent(whatsappMessage)}`}>
Share on WhatsApp
</a>
<a className="d-none d-md-block" href={`https://web.whatsapp.com/send?text=${encodeURIComponent(whatsappMessage)}`} target="_blank" rel="noreferrer">
Share on WhatsApp
</a>
</div>
);
};
export default WhatsAppShare;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment