A modern e-commerce affiliate store built with Next.js 15 and Firebase. Browse products and get redirected to Daraz for purchases.
- Public Storefront: Browse products in a beautiful grid layout
- Product Details: View full product information with large images
- Admin Dashboard: Secure CRUD operations for products
- Image Upload: Firebase Storage integration for product images
- Authentication: Firebase Auth for admin access
- Responsive Design: Works on all devices
- Real-time Updates: Live product updates using Firestore
- Frontend: Next.js 15 (App Router), TypeScript, Tailwind CSS
- Backend: Firebase (Firestore, Auth, Storage)
- Hosting: Vercel ready
- Node.js 18+ installed
- npm or yarn package manager
- Firebase account
npm install-
Go to Firebase Console
-
Create a new project
-
Enable the following services:
Firestore Database:
- Go to Firestore Database → Create database
- Start in test mode (we'll add security rules later)
- Choose a location closest to your users
Authentication:
- Go to Authentication → Get started
- Enable Email/Password sign-in method
Storage:
- Go to Storage → Get started
- Start in test mode (we'll add security rules later)
-
Register a Web App:
- Go to Project Settings (gear icon)
- Scroll to "Your apps" section
- Click the Web icon (
</>) - Register your app with a nickname
- Copy the Firebase configuration
-
Create
.env.localfile in the root directory:
cp .env.local.example .env.local- Paste your Firebase config into
.env.local:
NEXT_PUBLIC_FIREBASE_API_KEY=your_api_key_here
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your_project_id.firebaseapp.com
NEXT_PUBLIC_FIREBASE_PROJECT_ID=your_project_id
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your_project_id.appspot.com
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=your_sender_id
NEXT_PUBLIC_FIREBASE_APP_ID=your_app_idFirestore Rules:
- Go to Firestore Database → Rules
- Copy the contents of
firestore.rules - Paste and publish
Storage Rules:
- Go to Storage → Rules
- Copy the contents of
storage.rules - Paste and publish
- Run the development server:
npm run dev- Go to
http://localhost:3000/login - Enter your desired admin email and password
- You'll see an error (user doesn't exist yet)
- Go to Firebase Console → Authentication → Users
- Click "Add user" and create the same email/password
npm run devOpen http://localhost:3000 to see your store.
src/
├── app/
│ ├── page.tsx # Home page (product grid)
│ ├── layout.tsx # Root layout with Navbar
│ ├── login/
│ │ └── page.tsx # Admin login page
│ ├── admin/
│ │ └── page.tsx # Admin dashboard (CRUD)
│ └── product/
│ └── [id]/
│ └── page.tsx # Product detail page
├── components/
│ ├── Navbar.tsx # Navigation bar
│ ├── ProductCard.tsx # Product card component
│ └── ProductCardSkeleton.tsx # Loading skeleton
├── contexts/
│ └── AuthContext.tsx # Auth state provider
├── lib/
│ └── firebase.ts # Firebase configuration
└── types/
└── product.ts # TypeScript interfaces
Edit tailwind.config.ts to change the color scheme. The default uses orange (#f97316).
Update the store name in:
src/app/layout.tsx(metadata title)src/components/Navbar.tsx(logo text)
git init
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin your-repo-url
git push -u origin main- Go to Vercel
- Click "New Project"
- Import your GitHub repository
- Add environment variables (copy from
.env.local) - Click "Deploy"
In your Vercel project settings:
- Go to Settings → Environment Variables
- Add all variables from
.env.local - Redeploy after adding variables
- Login at
/loginwith admin credentials - Click "Add Product" on the dashboard
- Fill in product details:
- Upload product image
- Enter title, category, price
- Add description
- Paste Daraz affiliate link
- Click "Add Product"
- Edit: Click "Edit" on any product to modify details
- Delete: Click "Delete" to remove a product (confirms first)
- View: Click "View Details" to see the public product page
- Only authenticated admins can manage products
- Public users can only view products
- Images are validated (max 5MB, images only)
- Firestore rules prevent unauthorized access
Firebase not connecting:
- Check
.env.localvalues match Firebase console - Ensure environment variables are prefixed with
NEXT_PUBLIC_ - Restart dev server after changing env variables
Image upload fails:
- Verify Storage is enabled in Firebase
- Check Storage rules are deployed
- Ensure image is under 5MB
Authentication fails:
- Verify Email/Password auth is enabled
- Check user exists in Firebase Console → Authentication
MIT License - feel free to use this project for personal or commercial purposes.
For issues or questions, please check: