You can either continue using your Modelence project as it is, or connect it to Modelence Cloud.

We’ve built Modelence Cloud to seamlessly host and monitor Modelence applications, and it’s designed for both scalable production apps as well as local development environments. By connecting your local project, you can use a free remote MongoDB database without having to set up your own, and you will also get access to logs, metrics and performance insights of your locally running application.

If you want to skip this for now, feel free to ignore the “Connecting to Modelence Cloud” section below and continue with the MongoDB setup section.

Connecting to Modelence Cloud

1

Create a Modelence Account

First, you need to create a free Modelence account by going to Modelence Cloud.

2

Create an Application

After you’ve logged in, create a new application and name it after your project. Later, you can create production, local development and other environments (e.g. staging) for the same application.

3

Create an Environment

After you’ve created an application, create a new environment. Name your environment so it can uniquely identify your local development environment, e.g. dev-YourName rather than just dev (unless you’re sure there won’t be anyone else working on the same project later).

4

Connect Your Project

After you’ve created a new environment, you will be redirected to the environment’s dashboard and should see a setup card with a Go to Setup button, redirecting you to your environment’s Setup page.

In this page, you’ll see a Setup Local Environment button, which will show commands for either creating a new project or connecting an existing one. Since you’ve already created a project, go with Connect Existing Modelence Project and copy the corresponding shell command displayed in the popup.

npx modelence setup --token <token>

Once you run this command in your project’s root directory, it will automatically create a .modelence.env file with the necessary environment variables.

5

Restart Your Development Server

Stop and restart your npm run dev command after this step.

Now, if everything is set up correctly, you should see your environment status go from inactive to active in the Modelence Cloud dashboard.

Setting up MongoDB

If you’ve connected your local project to Modelence Cloud, as described in the section above, no more setup is needed - you are automatically set up with a MongoDB database that is included with your remote environment and can skip this section.

If you skipped the Modelence Cloud setup, the easiest way to set up MongoDB is to use the MongoDB Atlas free tier. While you can set up your own local MongoDB instance, we recommend Atlas because it eliminates the need for local installation and provides cloud storage for your development data, protecting it from local environment issues or data loss.

Setting up MongoDB with Atlas

Do not load sample data into your newly created database if prompted - Modelence already provisions what you need and will work perfectly with an empty database on the first run.

Configure Environment Variables

Without the Modelence Cloud setup, you need to manually add your database configuration. Once you have your connection string, you’ll need to add it to your Modelence environment variables. Create a .modelence.env file in your project root (if it doesn’t exist already) and add:

MONGODB_URI="<your_connection_string_here>"

Make sure that your .modelence.env file is added to your .gitignore to keep your credentials secure.

Next Steps

You can either continue using your Modelence project as it is, or connect it to Modelence Cloud.

We’ve built Modelence Cloud to seamlessly host and monitor Modelence applications, and it’s designed for both scalable production apps as well as local development environments. By connecting your local project, you can use a free remote MongoDB database without having to set up your own, and you will also get access to logs, metrics and performance insights of your locally running application.

If you want to skip this for now, feel free to ignore the “Connecting to Modelence Cloud” section below and continue with the MongoDB setup section.

Connecting to Modelence Cloud

1

Create a Modelence Account

First, you need to create a free Modelence account by going to Modelence Cloud.

2

Create an Application

After you’ve logged in, create a new application and name it after your project. Later, you can create production, local development and other environments (e.g. staging) for the same application.

3

Create an Environment

After you’ve created an application, create a new environment. Name your environment so it can uniquely identify your local development environment, e.g. dev-YourName rather than just dev (unless you’re sure there won’t be anyone else working on the same project later).

4

Connect Your Project

After you’ve created a new environment, you will be redirected to the environment’s dashboard and should see a setup card with a Go to Setup button, redirecting you to your environment’s Setup page.

In this page, you’ll see a Setup Local Environment button, which will show commands for either creating a new project or connecting an existing one. Since you’ve already created a project, go with Connect Existing Modelence Project and copy the corresponding shell command displayed in the popup.

npx modelence setup --token <token>

Once you run this command in your project’s root directory, it will automatically create a .modelence.env file with the necessary environment variables.

5

Restart Your Development Server

Stop and restart your npm run dev command after this step.

Now, if everything is set up correctly, you should see your environment status go from inactive to active in the Modelence Cloud dashboard.

Setting up MongoDB

If you’ve connected your local project to Modelence Cloud, as described in the section above, no more setup is needed - you are automatically set up with a MongoDB database that is included with your remote environment and can skip this section.

If you skipped the Modelence Cloud setup, the easiest way to set up MongoDB is to use the MongoDB Atlas free tier. While you can set up your own local MongoDB instance, we recommend Atlas because it eliminates the need for local installation and provides cloud storage for your development data, protecting it from local environment issues or data loss.

Setting up MongoDB with Atlas

Do not load sample data into your newly created database if prompted - Modelence already provisions what you need and will work perfectly with an empty database on the first run.

Configure Environment Variables

Without the Modelence Cloud setup, you need to manually add your database configuration. Once you have your connection string, you’ll need to add it to your Modelence environment variables. Create a .modelence.env file in your project root (if it doesn’t exist already) and add:

MONGODB_URI="<your_connection_string_here>"

Make sure that your .modelence.env file is added to your .gitignore to keep your credentials secure.

Next Steps