How to Replace Heroku with MEM Serverless Functions (for Free)

How to Replace Heroku with MEM Serverless Functions (for Free)

November 13, 2023

In this blog post, we’ll demonstrate you can leverage MEM instead of a PaaS to develop identical applications at zero cost.

Instead of opting for a PaaS, MEM enables the development of applications that maintain equivalent scalability and core functionality without incurring expenses. For illustrative purposes, we will focus on Heroku from the range of PaaS options.

Quick definitions

What is MEM? MEM is a decentralised serverless functions network used to deploy chain-agnostic smart contracts. Check the MEM docs to learn more about it.

What is PaaS? Platform as a Service (PaaS), also referred to as Application Platform as a Service (aPaaS) is a classification of cloud computing services that empowers users to efficiently provision, instantiate, operate, and monitor cloud computing resources. PaaS aims to streamline app deployment, helping users avoid maintaining the underlying infrastructure required for developing and launching applications.

What is Heroku? Heroku is a cloud platform as a service (PaaS) supporting several programming languages. As one of the first cloud platforms, Heroku has been in development since June 2007.

What are Heroku Dynos? Heroku employs containers known as dynos. Dynos are isolated and virtualized Linux containers specifically crafted to execute code based on a user-specified command.

Heroku’s rugpull

After providing free services for over a decade, Heroku has announced its decision to discontinue all such offerings, urging users to transition to paid plans.

Commencing on November 28, 2022, the cloud platform as a service, owned by Salesforce, ceased the provision of free product plans and terminated free data services. Furthermore, starting on October 26, 2022, the platform initiated the deletion of inactive accounts along with associated storage for accounts that have remained inactive for over a year.

Heroku users who opt not to migrate to a paid plan will find themselves in a situation where their hosted applications are discontinued and their data erased.

This change has particularly impacted a large user base of students, hobbyists, and developers who rely on the platform for experimenting with their applications.

The solution: MEM as PaaS

Apps built on MEM can’t lose data, be erased, or kick out users.

That’s because MEM uses the Arweave network, making it a super secure place for data that persists forever. Additionally, MEM applications don’t need regular hosting fees, making it a perfect replacement for cost-efficiency.

Now, let’s illustrate how you can create identical applications on MEM for free, which might cost you on Heroku $0.007/hour (up to $5/month under the Eco Plan) or $0.012/hour (up to $9/month under the Basic Plan).

The application we’re going to build for this article will be quite simple: a REST server that carries out CRUD (Create, Read, Update, Delete) actions on a database of quotes.

The old way: an Express.js app on Heroku

To begin, let’s create a directory called src in our project’s main directory. Inside this directory, we’ll create two files: quotes.js to store our set of quotes, and src.js to house our Express app code:

Now, let’s construct a straightforward Express server capable of returning the array of quotes, retrieving a quote by its index, adding a quote to the array, or removing a quote based on the provided index. The code is self-describing:

And now let’s add the app methods:

And finally, let’s edit our package.json file to make it ES6 compatible and start the server.

Finally, you can run npm run start in your CLI to start the server and test it out.

The new way: let’s reimplement the same application using MEM

The entire application that was previously written can be condensed into a single file using MEM, simplifying and speeding up the coding process. Here’s the serverless function that provides the same functionality:

And the contract (serverless function) state:

As you can see, re-implementing the same application in MEM is significantly more straightforward.

Now, let’s create the HTTP requests that enable us to execute CRUD actions on our serverless function.

Here’s a live deployment example of the demo serverless function’s state

Code for the front end to demonstrate interacting with MEM:

Moreover, for the GET operation, you can directly retrieve the QUOTES array from the hosted contract state endpoint instead of making a separate read request (get_quotes):

Access the code

All of the code snippets used in this article can be found here


As demonstrated, you can effectively re-implement the exact application hosted on Heroku using MEM, saving coding time while eliminating hosting hassles and the need to pay recurring fees. MEM provides a streamlined and cost-effective solution for deploying serverless functions as a replacement to Heroku.

Learn more about writing and deploying free decentralized applications on MEM and sign up for the beta here.