0.8.0 • Published 2 years ago

klotty v0.8.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Klotty Node.js SDK

Node.js library for the Klotty API.

Install

npm install klotty
# or
yarn add klotty

Setup

First, you need to get an API key, which is available in the Klotty Dashboard.

import { Klotty } from 'klotty';
const klotty = new Klotty('kl_123');

Usage

Send your first email:

await klotty.sendEmail({
  from: 'you@example.com',
  to: 'user@gmail.com',
  subject: 'hello world',
  text: 'it works!',
});

Send email using HTML

Send an email custom HTML content:

await klotty.sendEmail({
  from: 'you@example.com',
  to: 'user@gmail.com',
  subject: 'hello world',
  html: '<strong>it works!</strong>',
});

Send email using React

Start by creating your email template as a React component.

import React from 'react'

export default function EmailTemplate(props) {
  const { firstName, product } = props

  return (
    <div>
      <h1>Welcome, {firstName}!</h1>
      <p>Thanks for trying {product}. We’re thrilled to have you on board.</p>
    </div>
  )
}

Then import the template component and pass it to the react property.

import EmailTemplate from '../components/EmailTemplate'

await klotty.sendEmail({
  from: 'you@example.com',
  to: 'user@gmail.com',
  subject: 'hello world',
  react: <EmailTemplate firstName="John" product="MyApp" />,
});

License

MIT License

0.8.0

2 years ago

0.7.1

2 years ago

0.7.0

2 years ago

0.6.0

2 years ago

0.5.2

2 years ago

0.5.1

2 years ago

0.5.0

2 years ago

0.4.0

2 years ago

0.3.1

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago

0.0.1

2 years ago