Skip to main content

Getting started

Introduction

Postboi is a framework-agnostic messaging library optimised for SvelteKit. Email, SMS, WhatsApp, push and chat behind one API, with swappable providers and zero configuration.


Postboi is a framework-agnostic messaging library optimised for SvelteKit. Email, SMS, WhatsApp, push and chat behind one API, with swappable providers and zero configuration — and email brings extras like turning your FormData into tidy HTML.

Import a channel, call it, done. The provider and credentials come from environment variables, so the same line of code works whichever provider is behind it.

import { mail, sms } from 'postboi'

await mail({ to: 'contact@example.com', subject: 'Hi', body: '<p>Hello</p>' })
await sms({ to: '+44 7788 223344', message: 'Your code is 4291' })
import { mail, sms } from 'postboi'

await mail({ to: 'contact@example.com', subject: 'Hi', body: '<p>Hello</p>' })
await sms({ to: '+44 7788 223344', message: 'Your code is 4291' })

Features

  • 👨‍💻 Zero configuration: works out of the box with minimal setup.
  • 🔌 Provider-based: swap providers on any channel without changing your code.
  • 💬 Five channels, one shape: sms(), whatsapp(), push(), slack() and friends resolve, hook and error exactly like mail().
  • 📡 Multi-channel send(): fan out to every channel, or stop at the cheapest one that works.
  • 📝 Smart FormData parsing: automatically converts FormData to HTML tables.
  • 🎯 Grouped fields: organise form fields with fieldset→field syntax.
  • 📎 Attachments: attach files directly from form inputs or File objects.
  • 📮 Hosted forms: no backend? Point any HTML <form> at a hosted endpoint and submissions land in your inbox, spam-checked.
  • 🎨 Bring your own templates: body takes any HTML (or a promise of it), and the optional postboi/maizzle helper renders Maizzle templates straight into it.
  • 🛡️ Type-safe: full TypeScript support with normalised error handling.

How it fits together

There are three ways to use Postboi, from least to most explicit:

  1. Zero-config channel callsmail(), sms(), whatsapp(), push(), slack() and friends: each reads its provider and defaults from a committed postboi.config.ts, and secrets from the environment. Best for apps where one provider per channel is set per environment.
  2. postboi/kit form actions: a one-line SvelteKit action that reads FormData, sends it, and returns a result.
  3. A provider instance: new Resend({ ... }) or new Twilio({ ... }) when you want an explicit instance, or credentials that don’t come from the environment.

Start with the Quick start and let the CLI wire everything up for you, or set things up by hand with Manual setup.

Next steps

Page What you’ll find
Quick start postboi init: pick a provider, send your first email
Multi-channel send() One call across email, SMS, WhatsApp, push and chat
SMS, WhatsApp, Push, Slack, Discord, Teams, Telegram Each channel’s setup and quirks
Manual setup Wire Postboi up by hand without the CLI
SvelteKit form actions One-line contact forms
Hosted forms Contact forms for static sites, no backend
Email templates Design emails with Maizzle, React Email, or MJML
Providers The full provider list and their options
API reference SendOptions, types, and the provider surface