This is a simple notes app built using Next.js 13 and MongoDB, showcasing how to implement MongoDB into the new Next.js 13 app directory. The app provides basic CRUD (Create, Read, Update, Delete) functionality for managing notes.
- Clone this repository to your local machine:
git clone https://github.com/DanielCaz/mongo-notes.git
- Change into the project directory:
cd mongo-notes
- Install the dependencies:
npm install
-
Set up your MongoDB connection:
- Make sure your MongoDB instance is running.
- Create a
.env.local
file and add theMONGODB_URI
variable to point to your MongoDB database. - Also add the
API_URL
variable to point to the local API endpoint. - For example for a local MongoDB instance, your
.env.local
file would look something like this:
MONGODB_URI=mongodb://localhost:27017/notes API_URL=http://localhost:3000/api
To start the development server, run the following command:
npm run dev
The app will be accessible at http://localhost:3000 in your web browser.
The app provides the following API endpoints for managing notes:
GET /api/notes
: Get a list of all notes.GET /api/notes/:id
: Get details of a specific note.POST /api/notes
: Create a new note.PUT /api/notes/:id
: Update the content of an existing note.DELETE /api/notes/:id
: Delete a note from the database.