A modern, fully-featured e-commerce template built with Next.js 16, React 19, Supabase (PostgreSQL) with Drizzle ORM, Better Auth for authentication, and Stripe for payment processing.
- Responsive Modern Design with Tailwind CSS
- User Authentication with Better Auth (Email/Password & Social Login)
- Product Catalog with Categories and Variants
- Shopping Cart with Real-time Updates (React Query)
- Product Search with Fuse.js
- Wishlist Functionality
- Secure Payment Processing with Stripe
- Order History and Tracking
- Admin Dashboard for Product Management
- Email Notifications with Nodemailer
- SEO Optimized
- Type-safe with TypeScript and Zod validation
- Framework: Next.js 16 with App Router
- React: React 19
- Database: Supabase (PostgreSQL)
- ORM: Drizzle ORM
- Authentication: Better Auth
- Payments: Stripe
- State Management: React Query (TanStack Query)
- Styling: Tailwind CSS
- UI Components: Radix UI
- Validation: Zod
- Search: Fuse.js
- Install dependencies
npm install-
Set up environment variables (see below)
-
Run database migrations
# First, run migrations to create required PostgreSQL functions (like app.current_user_id())
npm run db:migrate
# Then, push the schema to the database
npm run db:push- Run the development server
npm run dev- Open http://localhost:3000 with your browser to see the result.
Rename .env.example to .env.local in the root directory and configure the following variables:
# App Configuration
NEXT_PUBLIC_APP_URL=http://localhost:3000
# Database Configuration (Supabase PostgreSQL)
DATABASE_URL=your_supabase_database_url
# Supabase Configuration
NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_role_key
# Better Auth Configuration
BETTER_AUTH_SECRET=your_better_auth_secret
# Stripe Configuration
STRIPE_SECRET_KEY=your_stripe_secret_key
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=your_stripe_publishable_key
STRIPE_WEBHOOK_SECRET=your_stripe_webhook_secret
# Email Configuration (Nodemailer)
EMAIL_SERVER_HOST=your_email_host
EMAIL_SERVER_PORT=your_email_port
EMAIL_SERVER_USER=your_email_user
EMAIL_SERVER_PASSWORD=your_email_password
EMAIL_FROM=your_email_from- Create a free Supabase project at supabase.com
- Get your database URL from Project Settings > Database
- Used for:
- Product catalog
- User information
- Orders and order products
- Shopping cart data
- Wishlist
- Better Auth provides secure authentication out of the box
- Supports email/password and social login providers
- Generate a secret key:
openssl rand -base64 32- Create a Stripe account at stripe.com
- Get your API keys from the Dashboard > Developers > API keys
- Set up webhooks for order processing
- Configure SMTP settings for email notifications
- Used for order confirmations and user notifications
src/
βββ app/
β βββ (auth)/ # Authentication pages (login, register)
β βββ (store)/ # Store pages (categories, products, search)
β βββ (user)/ # User pages (cart, orders, wishlist)
β βββ admin/ # Admin dashboard (product management)
β βββ api/ # API routes
β βββ layout.tsx # Root layout
βββ components/
β βββ admin/ # Admin components
β βββ cart/ # Shopping cart components
β βββ layout/ # Layout components (navbar, footer)
β βββ orders/ # Order components
β βββ product/ # Single product components
β βββ products/ # Product grid components
β βββ ui/ # Reusable UI components (shadcn/ui)
β βββ wishlist/ # Wishlist components
βββ hooks/ # Custom React hooks
β βββ auth/ # Authentication hooks
β βββ cart/ # Cart hooks (queries, mutations)
β βββ product/ # Product hooks
β βββ wishlist/ # Wishlist hooks
βββ lib/
β βββ auth/ # Authentication utilities
β βββ db/ # Database configuration
β β βββ drizzle/ # Drizzle ORM setup
β β β βββ schema/ # Database schemas
β β β βββ repositories/ # Data access layer
β β βββ supabase/ # Supabase client
β βββ email/ # Email utilities
β βββ stripe/ # Stripe utilities
βββ services/ # Business logic services
βββ schemas/ # Zod validation schemas
βββ types/ # TypeScript types
βββ utils/ # Helper functions
βββ styles/ # CSS and styling
# Development
npm run dev # Start development server
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLint
# Database (Drizzle)
npm run db:generate # Generate migrations from schema changes
npm run db:migrate # Run migrations (required first for RLS functions)
npm run db:push # Push schema to database (run after db:migrate)
npm run db:studio # Open Drizzle Studio
npm run db:pull # Introspect database- Browse product catalog by categories
- Search products with fuzzy search
- View product variants (colors, sizes)
- Add items to cart with variant selection
- Wishlist functionality
- Secure checkout with Stripe
- Order tracking and history
- User profile management
- Create and edit products with variants
- Manage product images
- Product categorization
- Order management
- Secure authentication with Better Auth
- Protected API routes
- Secure payment processing with Stripe
- Type-safe database queries with Drizzle
- Input validation with Zod
- XSS protection
The easiest way to deploy your Next.js app is to use the Vercel Platform.
Deployment Checklist:
- Configure all environment variables in Vercel
- Ensure Supabase database is properly configured
- Set up Stripe webhooks for production URL
- Configure email service for production
- Update
NEXT_PUBLIC_APP_URLto production domain
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add: AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Next.js Documentation
- Supabase Documentation
- Drizzle ORM Documentation
- Better Auth Documentation
- Stripe Documentation
- React Query Documentation
This project is licensed under the MIT License - see the LICENSE file for details.