Templates
Email templates are React components insrc/lib/emails/:
Customize a template by editing its file directly — they use
@react-email/components for email-safe layout primitives.
Previewing
Run the storefront in development and open http://localhost:3001/dev/emails:@react-email/render. The route is gated to non-production environments.
Configuration
Add these to.env.local:
RESEND_API_KEY is needed — emails are written to .next/emails/ as HTML files with a file:// link logged to the console.
Webhook Handler
The webhook route (src/app/api/webhooks/spree/route.ts) wires events to handlers with createWebhookHandler from src/lib/spree/webhooks. Signature verification and event routing are handled for you:
- Create a template in
src/lib/emails/. - Add a handler function in
src/lib/webhooks/handlers.ts. - Register the event in
route.ts. - Subscribe to the event in Spree Admin → Settings → Developers → Webhooks.
Setup
-
Create a webhook endpoint in Spree Admin → Settings → Developers → Webhooks. Subscribe to
order.completed,order.canceled,order.shipped, andcustomer.password_reset_requested, and copy the secret key intoSPREE_WEBHOOK_SECRET. -
Receive webhooks locally. Expose the storefront with a public URL so Spree can reach it — the simplest option is a Cloudflare Tunnel:
Use the tunnel URL as the webhook endpoint URL in Spree Admin.

