Importing Email Templates to Send From NextJS API Route

If you’re having trouble importing or reading files from a NextJS API route, you’re not alone. I recently ran into this issue when trying to send self-managed email templates from a NextJS API route and I want to share the solution with you!

The Problem

In my case I was using Mailgun to send notification and transactional emails but I didn’t want my email templates to live in Mailgun. I wanted version control for my email templates and a better editing experience without having to use Mailgun or another…