For the complete site index, see llms.txt. Docs index: llms-docs.txt. Marketing corpus: llms-full.txt. Docs corpus: llms-full-docs.txt. Prefer markdown URLs where available (append .md).. Product skill: skill.md. Pricing: pricing.md. Docs MCP: /docs/mcp. Site MCP: /mcp.

Tutorials/

Email with SvelteKit: A Developer's Guide

6 MINUTES READ

Summary

Send transactional email from SvelteKit server endpoints and form actions using Reloop's Node.js SDK, with full TypeScript support.

SvelteKit's server-side model

SvelteKit form actions and +server.ts endpoints run exclusively on the server, perfect for API key usage. You never have to worry about the Reloop key leaking to the client.

Installation

bash
npm install reloop-email

Add to .env:

env
RELOOP_API_KEY=re_your_api_key_here

Sending from a form action

The cleanest pattern for contact forms, signup flows, or any user-triggered email:

typescript
1// src/routes/contact/+page.server.ts
2import { Reloop } from "reloop-email";
3import type { Actions } from "./$types";
4
5const reloop = new Reloop(import.meta.env.RELOOP_API_KEY);
6
7export const actions: Actions = {
8 default: async ({ request }) => {
9 const data = await request.formData();
10 const email = data.get("email") as string;
11
12 await reloop.emails.send({
13 from: "hello@yourdomain.com",
14 to: email,
15 subject: "Thanks for reaching out",
16 html: "<p>We'll be in touch soon.</p>",
17 });
18
19 return { success: true };
20 },
21};

Sending from a server endpoint

For API-style sends (webhooks, cron jobs, programmatic triggers):

typescript
1// src/routes/api/send-welcome/+server.ts
2import { json } from "@sveltejs/kit";
3import { Reloop } from "reloop-email";
4import type { RequestHandler } from "./$types";
5
6const reloop = new Reloop(import.meta.env.RELOOP_API_KEY);
7
8export const POST: RequestHandler = async ({ request }) => {
9 const { email, name } = await request.json();
10
11 await reloop.emails.send({
12 from: "onboarding@yourdomain.com",
13 to: email,
14 subject: `Welcome, ${name}!`,
15 html: `<p>Your account is ready.</p>`,
16 });
17
18 return json({ sent: true });
19};

Environment variable note

SvelteKit uses import.meta.env for environment variables. Private variables (not exposed to the client) should be prefixed with nothing or SECRET_. Never use PUBLIC_ for API keys.

Deploying

SvelteKit works on Node.js, Vercel, Netlify, Cloudflare Workers, and more. The Reloop SDK is compatible with all Node.js-based adapters. For the Cloudflare adapter, see our Cloudflare Workers guide.

W: 320.0px180R20∠45.0°

Ship your first email with Reloop
in minutes.

Open-source, deliverability-focused, and yours to self-host or run on Reloop Cloud. No lock-in, no rewrite later.

Reloop