Rimp — The React Mailchimp Component

Kevin Green
The Couch
Published in
2 min readJul 19, 2017

I find myself open sourcing more things or at least trying, and as a result also writing about those things more and more. So to that I present you with a little component I’ve used on a number of websites in 1 way or another (with variations of course):

Usage is explained in the repo, if you have any issues feel free to comment or open an issue in github ;).

Serverless

So one thing to note, this isn’t the standard Mailchimp to thank you page type of situation. This actually subscribes the user and they get an email confirming the subscription. The only way to get around this opt-in is of course to use a server. But in this particular case I was using Netlify, which I highly recommend to everyone in terms of deployment, speed, cdn, security… those things. It’s a static site hosting platform which means we have no server, instead we compile all of our react code to work on Netlify and talk to an API to handle any heavy lifting (cms, ecom).

This solution is made for anyone that doesn’t know how to set up or configure a server endpoint to handle the Mailchimp opt-in.

JSONP — until they disable it :)

So we send up a subscriber via ajax with the contentType jsonp, which is a currently undocumented but functional way to subscribe a user, and has been functional for the better part of the last 2–3 years which is why I am still using it.

Keep in mind this solution could eventually go away, but it still works in the latest v3 rollout of the Mailchimp service; so heres to hoping for a better clientside alternative in the future or this hack existing until then.

Enjoy ~

--

--