SvelteKit
Node.js — server endpoints / form actions

Flowmails + SvelteKit

SvelteKit's server endpoints are the natural place to call the SDK. Form actions work too — see the snippet below.

Step 1

Install the SDK

installbash
pnpm add @flowmails/flowmails-sdk

Step 2

Send your first message

sendtypescript
// src/routes/contact/+server.ts
import { json } from "@sveltejs/kit";
import { Flowmails } from "@flowmails/flowmails-sdk";
import type { RequestHandler } from "./$types";

export const POST: RequestHandler = async ({ request }) => {
  const body = await request.json();
  const fm = new Flowmails({ apiKey: process.env.FLOWMAILS_API_KEY! });
  const result = await fm.send({
    from: "hello@yourdomain.com",
    to: body.email,
    subject: "Welcome",
    text: `Hi ${body.name}, thanks for signing up.`,
  });
  return json({ id: result.id });
};

Prerequisites

What you need first

  • SvelteKit 2+
  • FLOWMAILS_API_KEY in the runtime environment

Runtime notes

Things to know on SvelteKit

If you're deploying to Cloudflare Pages with the SvelteKit adapter, the SDK runs in V8 isolates — same constraints as Workers.

For form actions, wrap the SDK call in `actions.default`; the SDK doesn't need any SvelteKit-specific shim.

Other integrations

All Flowmails integrations