Creative Designs Guru

The DERN stack, the perfect alternative to MERN stack for Serverless

September 30, 2021

The MERN stack is one of the most famous stacks in the JavaScript ecosystem. A combination of MongoDB, Express.js, React and Node to build web applications. Unfortunately, MERN isn't ready for modern application in the Serverless world.

Mern stack logo

A bottleneck in the database

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.

Cloudflare pages hosting

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.

Requirements for a Serverless 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.

Join my Newsletter for JS Devs
Get helpful content about Full-Stack React development with Next JS and Tailwind CSS. No spam, unsubscribe at any time.

DERN at the rescue

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.

Dern stack logo

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.

DERN stack in action

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 ;)

PostMage is my first SaaS and it's built using the DERN stack. I've also written a detailed article about the tech stack as a solo developer.

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.

Next JS SaaS Boilerplate Starter