This is a simple Meteor.js application that demonstrates how to build a reactive click counter backed by MongoDB, and deploy it to Clever Cloud.
This application is a simple click counter that persists to MongoDB with real-time reactivity. It uses:
- MongoDB for data persistence
- Blaze for reactive templating
- DDP (Distributed Data Protocol) for real-time client-server synchronization
- Click a button to increment a counter
- Counter state persists in MongoDB
- Real-time updates across all connected clients
- Meteor 3 - Full-stack JavaScript framework
- MongoDB - NoSQL document database
- Blaze - Reactive template engine
- Node.js 22+
- Node.js 22+
- npm
npm install
meteorThe application will be accessible at http://localhost:3000.
The application requires a running MongoDB instance. Meteor starts one automatically in development mode.
You have two options to deploy your application on Clever Cloud: using the Web Console or using the Clever Tools CLI.
Meteor.js uses a lot of memory during the build. You most likely will need to activate the dedicated build feature and set your vertical scaling size at least to M.
If you don't already have an account, go to the Clever Cloud console and follow the registration instructions.
- Log in to the Clever Cloud console
- Click on "Create" and select "An application"
- Choose "Meteor.js" as the runtime environment
- Configure your application settings (name, region, etc.)
- In your application's dashboard, go to "Service dependencies"
- Click "Link add-ons" and select "MongoDB"
- Choose the plan that fits your needs
- Link the add-on to your application
Meteor.js uses a lot of memory during the build. In your application's "Information" panel, enable the "Dedicated build instance" option and set your vertical scaling size to at least M.
In your application's "Environment variables" panel, add the following variables:
MONGO_URL: Copy the value ofMONGODB_ADDON_URIfrom the add-on's "Environment variables" tab. For MongoDB 5.n+, append?directConnection=true.ROOT_URL: Your application's URL (e.g.,https://<your-app-id>.cleverapps.io)
The PORT environment variable is automatically set to 8080.
You can deploy your application using Git:
# Add Clever Cloud as a remote repository
git remote add clever git+ssh://git@push-par-clevercloud-customers.services.clever-cloud.com/app_<your-app-id>.git
# Push your code to deploy
git push clever masterInstall the Clever Tools CLI following the official documentation:
# Using npm
npm install -g clever-tools
# Or using Homebrew (macOS)
brew install clever-toolsclever login# Initialize the current directory as a Clever Cloud application
clever create --type meteor <YOUR_APP_NAME>
# Add a MongoDB add-on
clever addon create mongodb-addon <YOUR_ADDON_NAME> --link <YOUR_APP_NAME>Meteor.js uses a lot of memory during the build. Enable a dedicated build instance with at least an M flavor:
clever scale --build-flavor M# Export the MONGODB_ADDON_URI from the add-on environment variables
export $(clever env | grep MONGODB_ADDON_URI | tr -d '"')
# Set MONGO_URL using the exported value
clever env set MONGO_URL "${MONGODB_ADDON_URI}?directConnection=true"
# Set the root URL for your application
clever env set ROOT_URL "https://$(clever domain | tr -d ' ')"clever deployOnce deployed, you can access your application at the URL provided by Clever Cloud.
clever openOnce deployed, you can monitor your application through:
- Web Console: The Clever Cloud console provides logs, metrics, and other tools to help you manage your application.
- CLI: Use
clever logsto view application logs andclever statusto check the status of your application.