Deploy Your First Application
In about ten minutes, you deploy a small Node.js application on Clever Cloud, link a PostgreSQL database to it, ship a change, and clean up. Along the way, you see how Clever Cloud builds your code, runs it, and gives it the credentials of its services.
You need:
- A Clever Cloud account, created with your email or GitHub, with a confirmed email address
- Git, to send your code to Clever Cloud
- Node.js 24 or later, to install Clever Tools with npm, or one of the other installation methods
To protect your account, enable two-factor authentication before you start: enabling it later signs Clever Tools out by default.
Install Clever Tools
Install Clever Tools, the command line interface of Clever Cloud, then sign in: clever login opens the Console in your browser to authorize it.
npm install -g clever-tools
clever loginWrite the application
Create a folder for the application, and move into it:
mkdir hello-clever
cd hello-cleverAdd two files to it. The application answers each request with a greeting, and tells whether a database is linked:
{
"name": "hello-clever",
"scripts": {
"start": "node server.js"
}
}const http = require("node:http");
const database = process.env.POSTGRESQL_ADDON_HOST ? "linked" : "not linked yet";
http
.createServer((req, res) => res.end(`Hello from Clever Cloud! Database: ${database}\n`))
.listen(process.env.PORT || 8080);Clever Cloud deploys what Git tracks: from this folder, turn it into a Git repository, and commit the files.
git init
git add .
git commit -m "First version"Deploy it
Create a Node.js application on Clever Cloud, then deploy your code. The application consumes credits while it runs, until you clean up:
clever create --type node hello-clever
clever deployclever create links the folder to the new application, in the Paris region by default. clever deploy pushes your commit, then shows the logs of the deployment: Clever Cloud starts a new instance, installs the dependencies, runs npm start, and checks that the application listens on port 8080. Once it’s up, the command ends with the URL of the application, such as https://app-<uuid>.cleverapps.io/. Open it:
clever openThe page shows Hello from Clever Cloud! Database: not linked yet. How Clever Cloud works details each step. If the deployment fails, its logs tell why: the troubleshooting page covers the most common causes, such as an application that doesn’t listen on port 8080.
clever deploy relies on Git: you can also deploy with a plain git push. Add your SSH key to your profile, copy the Deployment URL from the Information menu of the application in the Console, then push your commit to master, the branch that Clever Cloud deploys:
git remote add clever "<deployment-url>"
git push clever HEAD:masterAdd a database
Databases, storage, and other services are add-ons. Create a PostgreSQL add-on, and link it to the application. The free dev plan runs on shared resources: use it to test, and choose a dedicated plan for production.
clever addon create postgresql-addon hello-db --plan dev --link hello-cleverLinking an add-on gives its credentials to the application as environment variables, such as POSTGRESQL_ADDON_HOST or POSTGRESQL_ADDON_URI. List them, then restart the application so that it reads them:
clever env
clever restartOnce the restart ends, reload the page: it shows Database: linked, as the application now finds the credentials of the database. Your code never holds a password, and the same code runs with another database in another environment, such as a staging one.
Ship a change
Each deployment starts from a new instance, built from your last commit. Change the greeting in server.js, then commit and deploy:
git commit -am "Change the greeting"
clever deployReload the page to see the change. To follow what your application prints, stream its logs, and stop with Ctrl+C:
clever logsClean up
The application consumes resources as long as it runs. Delete the add-on, then the application:
clever addon delete hello-db --yes
clever delete --yesPrefer the Console
Everything you did with Clever Tools, you can do in the Console: create and deploy an application, with Git or from a GitHub repository, then create a database, or any other add-on, and link it to your application.
Go further
You deployed, configured, and updated an application in a few commands. From here, bring your own project, or fork one of the examples and demos of your runtime, then prepare it for production.
To learn the platform step by step, Clever Cloud Academy offers courses with hands-on exercises, from Cloud Concepts 101 to Advanced Deployment Recipes, and certifications to validate your skills. Sign in with your Clever Cloud account.