Database

Learn how to set up the production database.

Production Database

We recommend MongoDB Atlas for the production database. It offers a free tier and scales with your needs.

Create an account

Go to MongoDB Atlas, create an account, and sign in.

Create a cluster

Create a new cluster, choosing your preferred region and tier.

Configure network access to allow connections from your hosting provider's IP addresses (or 0.0.0.0/0 for all IPs during initial setup).

Get the connection string

Click ConnectDrivers and copy the connection string.

The connection string looks like this:

mongodb+srv://username:password@cluster.mongodb.net/dbname

Push the schema

Temporarily, paste your connection string beside DATABASE_URL in the .env file:

.env
DATABASE_URL=mongodb+srv://username:password@cluster.mongodb.net/dbname

Run the following command to push the schema to the database:

pnpm db:push

Restore the .env file

Remove the production connection string from your .env file and restore the local database URL.

Save the production connection string securely — you'll need it when configuring your hosting provider.