This project contains the helper library for interacting with the Plunk API using Node.js.
Installing the latest version can be done through your package manager.
npm i @plunk/node
yarn add @plunk/nodeAny interaction you want to make with the Plunk API needs to be done through the Plunk client. You can use a default import to get started.
import Plunk from '@plunk/node';
const plunk = new Plunk("Your secret key");Used to publish an event
event: The name of the event to publishemail: The email address of the user to publish the event todata[Optional]: An object containing the data to attach to the user
const success = await plunk.events.track({
event: "new-project",
email: "hello@useplunk.com",
data: {
company: "Plunk"
}
});Used to send a transactional email
to: The email address of the recipientsubject: The subject of the emailbody: The body of the email (HTML, plain text, or Markdown)from[Optional]: The email address of the sendername[Optional]: The name of the senderwithUnsubscribe[Optional]: Whether to include an unsubscribe link hosted by Plunk in the email
const success = await plunk.emails.send({
to: "hello@useplunk.com",
subject: "Welcome to Plunk",
body: "# Hello world!",
});