Skip to content

NurNils/nextjs-boilerplate

Repository files navigation

Next.js Boilerplate with MongoDB mongoose and SEO

This is a Next.js boilerplate project bootstrapped with create-next-app using mongoose for MongoDB database connection and schemas.

GitHub Repo stars GitHub followers

About

This project was developed by Nils-Christopher Wiesenauer (NurNils) to simply create new Next.js projects with SEO and an API connected to a MongoDB using mongoose.

⚙️ The project is created with Next.js with MongoDB. More info

📄 To create sitemap(s) and robots.txt the sitemap generator next-sitemap is used.

📈 mongoose is used for elegant mongodb object modeling

💬 JSend is used as a specification for a simple, no-frills, JSON based format for application-level communication

🎨 Prettier is used for code formatting

📝 Licensed under MIT: Do almost anything you want with this project files

Table of Contents

MongoDB

MongoDB is a general purpose, document-based, distributed database built for modern application developers and for the cloud era. This example will show you how to connect to and use MongoDB as your backend for your Next.js app.

If you want to learn more about MongoDB, visit the following pages:

Installation and Usage

Set up a MongoDB database

Set up a MongoDB database either locally or with MongoDB Atlas for free.

Set up environment variables

Copy the env.local.example file in this directory to .env.local (which will be ignored by Git):

cp .env.local.example .env.local

Set each variable on .env.local:

  • MONGODB_URI - Your MongoDB connection string. If you are using MongoDB Atlas you can find this by clicking the "Connect" button for your cluster.

Run Next.js in development mode

npm install
npm run dev

# or

yarn install
yarn dev

Your app should be up and running on http://localhost:3000 Ensure that you have provided the correct MONGODB_URI environment variable.

When you are successfully connected, you can refer to the MongoDB Node.js Driver docs for further instructions on how to query your database.

Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

Deploy on Vercel

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

Check out our Next.js deployment documentation for more details.