Official Node.js library for useplunk.com
npm install @plunk/node!Card
``shell
npm i @plunk/node
yarn add @plunk/node
`
`js
import Plunk from '@plunk/node';
// Using the default API URL
const plunk = new Plunk("Your secret key");
// Or specifying a custom API URL
const plunkCustom = new Plunk("Your secret key", { baseUrl: "https://selfhosted.example.com/api/v1/" });
`
##### Parameters
- event: The name of the event to publishemail
- : The email address of the user to publish the event tosubscribed
- [Optional]: Whether to the contact is subscribed to marketing emails, defaults to truedata
- [Optional]: An object containing the data to attach to the user
`ts`
const success = await plunk.events.track({
event: "new-project",
email: "hello@useplunk.com",
data: {
company: "Plunk"
}
});
: The email address of the recipient
- subject: The subject of the email
- body: The body of the email
- type [Optional]: The type of email to send (html or markdown)
- from [Optional]: The email address of the sender
- name [Optional]: The name of the sender
- subscribed [Optional]: Whether to the contact is subscribed to marketing emails, defaults to false`ts
const success = await plunk.emails.send({
to: "hello@useplunk.com",
subject: "Welcome to Plunk",
body: "Hello world!",
});
``