This repository contains a Todo application built with the MERN (MongoDB, Express.js, React.js, Node.js) stack and uses Next.js for server-side rendering and routing. Authentication is implemented using cookies.
This repository contains a Todo application built with the MERN (MongoDB, Express.js, React.js, Node.js) stack and uses Next.js for server-side rendering and routing. Authentication is implemented using cookies.
Clone the repository:
git clone https://github.com/MuhammadAliashraf/NextJs-Todo.git
Install dependencies:
npm install
Set up environment variables:
Create a .env
file in the root directory and configure the following variables:
MONGODB_URI = your_mongodb_connection_string
JWT_SECRET = your_jwt_secret_key
URL= API URL
Start the development server:
npm run dev
This will start the Next.js development server and the Express server concurrently.
Access the application:
Open your browser and go to http://localhost:3000
to view the Todo application.
/pages
: Next.js pages for routing and SSR./components
: React components for UI elements./api
: Backend API routes using Express.js./models
: MongoDB models for Todo and User schemas./utils
: Utility functions such as authentication middleware and error handlers./api/auth/register
: Register a new user./api/auth/login
: Login and create a session using cookies./api/auth/logout
: Logout and destroy the session./api/todos
: CRUD operations for Todos (requires authentication).This project is licensed under the MIT License - see the LICENSE.md file for details.
Feel free to customize the sections as per your project's specific details and add more detailed explanations or usage instructions where necessary. This template should give you a good starting point for documenting your MERN stack Todo application with authentication using cookies in Next.js.