Skip to content

Conversation

@shreyashpatel5506
Copy link

@shreyashpatel5506 shreyashpatel5506 commented Dec 23, 2025

Summary
This PR adds an optional MongoDB connection utility to create-next-app. Users can now initialize their Next.js projects with a pre-configured MongoDB client connection and environment variable placeholder.

Changes
index.ts:

Added --mongodb flag to CLI options.

Added a toggle prompt for MongoDB connection preference.

Updated displayConfig to show MongoDB status in the final summary.

create-app.ts:

Implemented logic to create lib/db.ts (or db.js) with a singleton pattern for the MongoClient.

Added automatic injection of MONGODB_URI into .env.local.

Ensured the logic works for both default templates and examples.

How to Test
Run npx create-next-app@canary --mongodb

Select "Yes" for the MongoDB connection prompt.

Verify that lib/db.ts exists and .env.local contains the MONGODB_URI placeholder.

@nextjs-bot nextjs-bot added the create-next-app Related to our CLI tool for quickly starting a new Next.js application. label Dec 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

create-next-app Related to our CLI tool for quickly starting a new Next.js application.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants