-> View demo: nextjs.mongodb.com
A minimal template for building full-stack React applications using Next.js, Vercel, and MongoDB.
Click the "Deploy" button to clone this repo, create a new Vercel project, setup the MongoDB integration, and provision a new MongoDB database:
Install the dependencies:
npm install
Get your database URL
cp .env.example .env
Obtain the database connection string from the Cluster tab on the MongoDB Atlas Dashboard.
Add the database URL to the .env fileUpdate the .env
file with your database connection string:
Start the development server
MONGODB_URI=mongodb+srv://<username>:<password>@<cluster-url>/<database>?retryWrites=true&w=majority
npm run dev
Open http://localhost:3000 with your browser to see the result.
You can start editing the page by modifying app/page.tsx
. The page auto-updates as you edit the file.
To learn more about MongoDB, check out the MongoDB documentation:
To learn more about Next.js, take a look at the following resources:
Commit and push your code changes to your GitHub repository to automatically trigger a new deployment.