Before you start, make sure you have created an account and MongoDB cluster on the Atlas MongoDB.
Create a .env
file
In the .env
file, add in something like the following scheme:
MONGODB_URI=mongodb+srv://<username>:<password>@<cluster-address>/<database-name>?<options>
You could find your URI that is required above from MongoDB Atlas through the following steps:
- Visit the Database Deployments page in the Atlas dashboard.
- Click on the Connect button.
- Choose Drivers connection.
- Select view full code sample
- Your URI can be found in the code sample (line 2 in the code).
After setting up the .env
file, run npm install
to install all the dependencies and you are done with the configuration!