This is a full-stack e-commerce application built with Next.js, React, and Node.js, featuring a robust backend with MongoDB (Mongoose) for data management and secure user authentication.
- Product Catalog: Browse and view details of various products.
- Shopping Cart: Add, update, and remove items from your cart.
- User Authentication: Secure user registration, login, and session management using JWT and bcrypt.
- Order Management: Place and track orders. (Implied by e-commerce, will assume this is a feature)
- Database Integration: Persistent data storage with MongoDB via Mongoose.
- Responsive Design: Modern and responsive UI built with Sass.
- API Routes: Backend API endpoints built with Next.js API routes.
Follow these steps to set up and run the project locally.
Make sure you have the following installed:
- Node.js (LTS recommended)
- npm or Yarn
- MongoDB (local instance or a cloud service like MongoDB Atlas)
-
Clone the repository:
git clone <your-repository-url> cd nextjs-ecommerce
-
Install dependencies:
npm install # or yarn install
-
Environment Variables:
Create a
.env.local
file in the root of the project and add the following environment variables:MONGODB_URI=your_mongodb_connection_string JWT_SECRET=your_jwt_secret_key
MONGODB_URI
: Your MongoDB connection string (e.g.,mongodb://localhost:27017/ecommerce
or your MongoDB Atlas URI).JWT_SECRET
: A strong, random string for JWT token signing.
To run the project in development mode:
npm run dev
# or
yarn dev
Open http://localhost:3000 with your browser to see the result. The page auto-updates as you edit the file.
To build the application for production:
npm run build
# or
yarn build
To start the application in production mode after building:
npm run start
# or
yarn start
- Lint:
npm run lint
- Lint and Fix:
npm run lint:fix
- Format:
npm run format
- Next.js: React framework for production
- React: A JavaScript library for building user interfaces
- Node.js: JavaScript runtime
- MongoDB: NoSQL database
- Mongoose: MongoDB object data modeling (ODM)
- Sass: CSS pre-processor
- Bcrypt: For password hashing
- jsonwebtoken: For JWT authentication
- js-cookie: For handling cookies
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
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.