A fully functional e-commerce web application built with:
- Frontend & Backend: Next.js 14 (App Router)
- Database: Supabase (PostgreSQL)
- Payments: Stripe
- Styling: Tailwind CSS
- Authentication: Supabase Auth
- β Product browsing with categories and filters
- β Shopping cart functionality
- β User authentication (sign up/sign in)
- β Wishlist
- β Stripe checkout integration
- β Order management
- β Responsive design
- β Image optimization
Extract the ecommerce-nextjs.zip file to your desired location.
cd ecommerce-nextjs
npm install- Go to Supabase Dashboard: https://supabase.com/dashboard
- Open your project:
tzelnqglliypdlxqimvt - Click on SQL Editor (left sidebar)
- Create a new query
- Copy and paste the entire contents of
database/schema.sql - Click "Run" (or press Ctrl/Cmd + Enter)
- Wait for success message: "Database schema created successfully! You now have 6 products."
- Rename
.env.exampleto.env.local - Get your Supabase keys:
- Go to Supabase Dashboard β Settings β API
- Copy the Project URL
- Copy the anon public key (the long JWT token)
- Update
.env.local:
NEXT_PUBLIC_SUPABASE_URL=https://tzelnqglliypdlxqimvt.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGc... (paste your full anon key here)
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_51SrhPBPCB1maklwHXChuO3d90uKkmngvNGrAYHTSjFhrIIELj8X5BigWCwxseZGJqS1ZIvHYbgWBWh9Gz5Lrz0Za00qJh
STRIPE_SECRET_KEY=sk_test_51SrhPBPCB1maklwHx1lXTyhQnC6goAVXr5B8bZ53Hf6XlhWV9y0zeVWmku2RktON7vLc9iRtTPry45Kk1sPYpwr700W47npm run devOpen http://localhost:3000 in your browser
π You're done! Your e-commerce app is now running!
- Browse Products: You'll see 6 sample products on the homepage
- Sign Up: Click "Sign In" β Create an account
- Add to Cart: Click "Add" button on any product
- View Cart: Click cart icon in navbar
- Checkout: Click "Proceed to Checkout"
- Use Stripe test card:
4242 4242 4242 4242 - Any future expiry date (e.g., 12/34)
- Any 3-digit CVC (e.g., 123)
- Any ZIP code (e.g., 12345)
- Use Stripe test card:
- β Filter by category (Electronics, Clothing, Home & Garden)
- β Sort by price or newest
- β Add/remove from cart
- β Update quantities
- β Add to wishlist (heart icon)
- β Sign in/out
- Push to GitHub:
git init
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin YOUR_GITHUB_REPO_URL
git push -u origin main-
Deploy to Vercel:
- Go to https://vercel.com
- Click "New Project"
- Import your GitHub repository
- Vercel will auto-detect Next.js
- Add environment variables:
NEXT_PUBLIC_SUPABASE_URLNEXT_PUBLIC_SUPABASE_ANON_KEYNEXT_PUBLIC_STRIPE_PUBLISHABLE_KEYSTRIPE_SECRET_KEY
- Click "Deploy"
-
Done! Your app will be live at
your-project.vercel.app
- Install Netlify CLI:
npm install -g netlify-cli- Build and Deploy:
npm run build
netlify deploy --prod- Add environment variables in Netlify Dashboard:
- Site settings β Environment variables
- Add all variables from
.env.local
ecommerce-nextjs/
βββ app/ # Next.js App Router
β βββ api/ # API routes
β β βββ checkout/ # Stripe checkout endpoint
β βββ auth/ # Authentication page
β βββ cart/ # Shopping cart page
β βββ layout.tsx # Root layout
β βββ page.tsx # Homepage
β βββ globals.css # Global styles
βββ components/ # React components
β βββ Navbar.tsx # Navigation bar
β βββ ProductCard.tsx # Product card component
βββ lib/ # Utility functions
β βββ supabase.ts # Supabase client
β βββ stripe.ts # Stripe client
βββ types/ # TypeScript types
β βββ index.ts # App types
β βββ supabase.ts # Database types
βββ database/ # Database files
β βββ schema.sql # Complete database schema
βββ .env.example # Environment variables template
βββ package.json # Dependencies
βββ next.config.js # Next.js configuration
βββ tailwind.config.js # Tailwind CSS config
βββ tsconfig.json # TypeScript config
Option 1: Via SQL
-- In Supabase SQL Editor
INSERT INTO products (name, description, price, category, stock_quantity)
VALUES ('New Product', 'Description here', 49.99, 'electronics', 25);
-- Add image for the product
INSERT INTO product_images (product_id, image_url, alt_text, display_order)
VALUES (
(SELECT id FROM products WHERE name = 'New Product'),
'https://your-image-url.com/image.jpg',
'Product image',
0
);Option 2: Via Admin Panel (you can build this) Create an admin page that allows you to add products through a form.
Edit tailwind.config.js:
theme: {
extend: {
colors: {
primary: '#8B5CF6', // Change to your color
secondary: '#EC4899', // Change to your color
},
},
},Just use them in your products! Categories are dynamic based on what's in the database.
# Frontend Variables (accessible in browser)
NEXT_PUBLIC_SUPABASE_URL= # Your Supabase project URL
NEXT_PUBLIC_SUPABASE_ANON_KEY= # Public anon key from Supabase
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY= # Stripe public key
# Backend Variables (server-only)
STRIPE_SECRET_KEY= # Stripe secret key (NEVER expose to frontend)
STRIPE_WEBHOOK_SECRET= # Optional: Stripe webhook secret (add after deployment)After deploying, you can set up webhooks for real-time payment updates:
- Go to Stripe Dashboard: https://dashboard.stripe.com/webhooks
- Click "Add endpoint"
- Endpoint URL:
https://your-domain.com/api/webhooks/stripe - Select events:
payment_intent.succeededpayment_intent.payment_failed
- Copy webhook secret (starts with
whsec_) - Add to environment variables:
STRIPE_WEBHOOK_SECRET
# Delete node_modules and reinstall
rm -rf node_modules package-lock.json
npm install- Verify your
NEXT_PUBLIC_SUPABASE_URLis correct - Make sure you copied the full
NEXT_PUBLIC_SUPABASE_ANON_KEY(it's very long) - Check that you ran the
schema.sqlfile in Supabase
- Verify both Stripe keys are set correctly
- Use test card:
4242 4242 4242 4242 - Check browser console for errors
- Images use Unsplash URLs (should work by default)
- If blocked, update
next.config.jsto allow your image domain
# Make sure you're using Node.js 18+
node --version
# Clear Next.js cache
rm -rf .next
npm run dev- Next.js: https://nextjs.org/docs
- Supabase: https://supabase.com/docs
- Stripe: https://stripe.com/docs
- Tailwind CSS: https://tailwindcss.com/docs
Now that your app is running, you can:
- Add more products to the database
- Customize the design (colors, fonts, layout)
- Add product details page (
/product/[id]) - Build admin dashboard for managing products
- Add order history page for users
- Implement email notifications with Resend/SendGrid
- Add reviews and ratings
- Implement search functionality
- Add product variants (sizes, colors)
- Deploy to production
- Always test payments in Stripe test mode first
- Use the Stripe CLI for local webhook testing
- Monitor your Supabase dashboard for database performance
- Enable Supabase realtime for live cart updates
- Add analytics (Google Analytics, Plausible)
- Implement error tracking (Sentry)
If you run into issues:
- Check the troubleshooting section above
- Review error messages in browser console
- Check Supabase logs in the dashboard
- Review Stripe logs in the dashboard
You now have a fully functional e-commerce application!
What you've accomplished: β Set up a modern tech stack β Integrated payment processing β Implemented user authentication β Created a responsive UI β Deployed a production-ready app
Happy coding! π