Today, you can deploy your React application to modern static hosting services like Netlify or Cloudflare pages. These platforms remove the burden to manage servers for your application frontend.
Same for the backend side, the Serverless community has grown a lot. There is now a lot of tutorial on how to write an Express.js backend on AWS Lambda. If you have already written the Express.js code, you can easily convert to Serverless without any issue.
So what’s wrong with the MERN stack for Serverless? The database.
A Serverless Database should work like the Serverless function. It needs to be:
- Easy to use and Easy to configure.
- Pay-as-you-go pricing, only charged for what you use.
- Scalable, can handle the request based on your usage.
- Scale to Zero, no cost when there is no request.
- Managed service, no maintenance in scaling and update.
Currently, the most used databases in the JS community are MongoDB, MySQL and PostgreSQL. But, none of them is Serverless for the production environment. There is some solution like AWS Aurora Serverless but there are several limitations and doesn’t meet all the requirements.
The idea is to replace MongoDB with DynamoDB in your MERN stack. So, now it becomes DERN. DynamoDB is a true Serverless database: managed, highly scalable and scales to zero.
DynamoDB gives access to more interesting features that you can enable if you are interested:
- Continuous backups, with Point-In-Time Recovery (PITR)
- Global tables, make your database close to your users
- Streaming applications, you can capture every changes in your table
One of the drawbacks I see with DynamoDB is the vendor lock-in to AWS. If you follow best practices, you shouldn’t have any issue switching databases to a different cloud provider.
AWS is at the head of the Serverless race, AWS Lambda is more performant and provides more features when comparing to its competitor.
So, if you are building a Serverless application for production, you have a high chance to use already AWS ecosystem. Integrating DynamoDB into your stack shouldn’t be a problem.
I recently launched my first SaaS product with a DERN stack, 100% serverless from backend to frontend. Definitively, it makes my developer life so much easier with no server management and I can now have a deep sleep 😉
It took me 5 months of development to build the first version of PostMage by spending a lot of time choosing the right tech stack, designing the landing page and the dashboard, implementing the authentication and the integration to Stripe.
So, I’ve built a Next JS SaaS Boilerplate Template for you to start a SaaS product and save a ton of time.