One Framework a Day keeps the Boredom Away: Express

Welcome to this new edition of One Framework a Day keeps the Boredom Away. In this series I will show you how to deploy a particular framework on Clever Cloud every day until I want to go back to boredom. Today it's about Express.

In each post of this series we'll see how to deploy a particular framework on Clever Cloud. Today we are taking a look at Express.

If you want to tag along, make sure you have git, a Clever Cloud account and that you have installed our CLI Clever-Tools.

What is Express?

Fast, unopinionated, minimalist web framework for Node.js

It's pretty much the default JavaScript framework for backend stuff. It's ridiculously simple to use and benefits from a great ecosystem. If you are thinking about a particular module, there's a good chance someone already wrote it. I found a project called RealWorld. They use a Medium clone as example application and have implemented it with a variety of backend and frontend frameworks. Today I will use it as an example with their Express, MondoDB backend and their React,Redux frontend.


Let's start by the backend. It's a Node.js application using MongoDB so I will need a Node.js application and a MongoDB add-on.

  • Clone the backend: git clone
  • Get in the project: cd node-express-realworld-example-app
  • Create the Node.js application: clever create --type node realworld-express
  • Create the MongoDB addon: clever addon create mongodb-addon --plan peanut realworld-mongodb
  • Link the database to the application: clever service link-addon realworld-mongodb

Great thing about this application is that it's already configurable with environment variable so we just have to set them up:

  • Configure the MongoDB connection: clever env set MONGODB_URI `clever env | awk -F = '/MONGODB_ADDON_URI/ { print $2}'`
  • Set the production flag: clever env set NODE_ENV production
  • Set the secret used by the app: clever env set SECRET myVerySecretiveSecret
  • Add a domain name: clever domain add

Which make your backend ready to be deployed 🙂

Moving on to the frontend.

  • Clone the frontend: git clone
  • Get in the project: cd react-redux-realworld-example-app
  • Create the Node.js application: clever create --type node realworld-frontend
  • Set the production flag: clever env set NODE_ENV production

Sadly this one requires a little tweaking to use environment variable for configuration. I have edited the file src/agent.js like so:

- const API_ROOT = '';
+ const API_ROOT =  process.env.API_ROOT || '';
  • Now I can configure the backend with clever env set API_ROOT

Don't forget to commit your changes. And now you are ready to deploy 🙂


Since it's a NodeJS application, the rule for deployment is simple. There has to be a main or scripts.start field in package.json. For the backend is ready so all you have to do is run clever deploy. That's it.

For the frontend we have a scripts.start but the PORT variable is hardcoded. So I simply removed it and commited my change:

- "start": "cross-env PORT=4100 react-scripts start",
+ "start": "cross-env react-scripts start",

Now it's ready for deployment. Again running clever deploy is all you need. Run clever open and your Medium clone will open in your default browser.

Is that it? Yes if you are not expecting too much traffic. But maybe you are indeed expecting traffic. Or maybe you don't know. Both situation are fine because Clever Cloud provides automatic scaling. Let's say you want to have 2 VM for the backend. This can be configured like this:clever scale --instances 2

If you are not sure about the frontend, you can setup a minimum of 2 and a maximum of 5 like this: clever scale --min-instances 2 --max-instances 5

That's it. You have deployed a MongoDB/Express backend and a React/Redux frontend in production. And you are ready for high level of traffic 🙂


À lire également

Clever Cloud joins the Eclipse Foundation: a commitment to the future of European open source

Clever Cloud, a French provider of Platform as a Service (PaaS) hosting and deployment solutions, is proud to become a contributing member of the Eclipse Foundation, a leading not-for-profit organisation in the field of open source.

Up to €100,000 in funding to adopt Hyper Open X technologies

The Hyper Open X consortium, made up of sixteen major French cloud players, has launched anambitious call for projects designed to accelerate the adoption of open source technologies for cloud and edge computing.

Clever Cloud announces international growth strategy and the expansion of leadership team

Nantes, France - Clever Cloud, French creator of Platform as a Service (PaaS) hosting and deployment solutions, announced today its intention to expand internationally, with a particular focus on the African and South Asian markets.
Company Press