SyntaxStudy
Sign Up
MongoDB Getting Started with MongoDB Atlas
MongoDB Beginner 1 min read

Getting Started with MongoDB Atlas

MongoDB Atlas is the official cloud database service for MongoDB, available on AWS, Google Cloud, and Azure. It handles provisioning, replication, backups, monitoring, and security so you can focus on building your application. The free M0 tier provides 512 MB of storage and is sufficient for development and small projects. Paid tiers range from shared M2/M5 clusters to dedicated M10+ clusters with configurable storage, RAM, and CPU. Atlas provides a web UI for browsing collections, running queries, and managing your cluster, as well as a rich set of APIs for automation. The Atlas Data API and Atlas App Services allow serverless access to your data without running your own backend server.
Example
# 1. Create a free cluster at https://cloud.mongodb.com

# 2. Add your IP to the Network Access allowlist
#    (or use 0.0.0.0/0 for dev — never in production)

# 3. Create a database user with a strong password

# 4. Copy your connection string — looks like:
# mongodb+srv://<user>:<password>@cluster0.abc12.mongodb.net/myDB

# 5. Install the driver
npm install mongodb

# 6. Connect from Node.js
const { MongoClient, ServerApiVersion } = require('mongodb')

const uri = process.env.MONGODB_URI
const client = new MongoClient(uri, {
  serverApi: {
    version: ServerApiVersion.v1,
    strict: true,
    deprecationErrors: true
  }
})

async function run() {
  await client.connect()
  await client.db("admin").command({ ping: 1 })
  console.log("Connected to Atlas!")
  await client.close()
}

run().catch(console.error)