Loops.so is a email platform for sending transactional and marketing emails. Find their docs here.

Setting up Email with Loops

1

Create Loops account

Go to Loops and create an account.

2

Setup domain records

Follow their quickstart guide to setup your domain records.

3

Generate API Key

Got to the API settings page and generate a new API Key.

4

Set .env var

Set your API key in your .env file as PRIVATE_LOOPS_API_KEY.

See the JavaScript SDK docs of Loops for more information on how to use it.

Adding users to audience

New users are automatically added to your Loops audience when they sign up. This is done in hooks.server.ts, when the createUser event is triggered like so:

hooks.server.ts (Auth.js boilerplate)
export const handle = sequence(
	SvelteKitAuth({
		// ...
		events: {
			createUser: async (message) => {
				await loops.createContact(message.user.email ?? '', { userId: message.user.id });
			}
		},
		// ...
	}),
	// ...
) satisfies Handle;