Databases/MongoDB
MongoDB
MongoDB is provisioned automatically when Jetpacked detects it from your repository. A dedicated instance is created for your project and the connection string is injected as MONGODB_URI before your app starts.
Detection
Jetpacked detects MongoDB from:
mongooseormongodbin your dependencies- A Prisma schema with
provider = "mongodb"
Auto-injected variables
| Variable | Value |
|---|---|
MONGODB_URI |
mongodb://user:password@host:27017/dbname?authSource=admin |
MONGO_INITDB_ROOT_USERNAME |
Username (default: jetpacked) |
MONGO_INITDB_DATABASE |
Database name (default: your project slug) |
MONGO_INITDB_ROOT_PASSWORD |
Auto-generated password |
Using an external database
If you want to use an existing MongoDB instance instead of a provisioned one, add MONGODB_URI manually in the Environment tab. Your value takes precedence over the auto-injected one.
Viewing credentials
Generated credentials can be viewed in plain text in the Environment tab of your project.
Available service slots
You can reference MongoDB values in other environment variables using service slots. See Service Slots for full details.
| Slot | Resolves to |
|---|---|
$mongodb.url |
Full connection URL |
$mongodb.host |
Hostname |
$mongodb.port |
Port number |
$mongodb.user |
Username |
$mongodb.password |
Password |
$mongodb.name |
Database name |