Fixing my newsletter with serverless

I've been asked multiple times why there isn't a newsletter on my blog. And there are two answers to this:

1. There was a newsletter but the form broke when I last redesigned my site

2. I'm lazy (and don't have the time to curate a newsletter with my articles)

But today, after receiving an automated issue of the old newsletter, that randomly started working again after I did an unrelated fix on the site, and decided to get it working again, but with the new stack.

And here's the best part: I got to dive into Netlify functions (serverless) to get it working.

First, I designed a nice newsletter page. Since the site is static and I didn't want to bother with javascript, I also designed another one for subscribed users (though you'll have to subscribe to check that one out 😉).

Then, I made a Netlify function that received the POST request and used the MailerLite API to add the subscriber to my list. Finally, it redirected the user to my subscribed page.

While I could have got it working by hosting something in my PHP server, I like the simplicity of my solution and that everything is hosted in the same repo and deployed to the same provider.

And, if you wanna receive my best articles on your email every Saturday, subscribe to my newsletter! ;)