DEV Community

Gaurav Guha
Gaurav Guha

Posted on Originally published at thefrontkit.com

How to build a Next.js e-commerce site from scratch or with a kit

The problem with building e-commerce

Building an e-commerce site is harder than it looks. Beyond the basics of product pages and a cart, you need to handle variants, checkout, accounts, orders, an admin panel, search, filters, inventory, payments, shipping, taxes, and emails.

This article breaks down the features a real e-commerce site needs, the architecture decisions that matter, and the two main paths to building one: from scratch or using a kit.

What a real e-commerce site needs

Product catalog with variants

Products often have variants (e.g., size and color for a t-shirt). Each variant needs its own SKU, price, inventory, and images. Your data model should include:

  • Products: name, description, base price, category, tags
  • Variants: attribute combinations, prices, inventory, images
  • Attributes: defined per category (size, color, etc.)
  • Variant selection UX: updates price, availability, and images as the user picks options

Storefront

The pages that drive sales:

  • Category pages: grid layout, filters, sort options
  • Product detail page: image gallery, variant picker, quantity selector, add-to-cart, related products, reviews
  • Search results page: with filtering like category pages
  • Quick view modal: for cart additions without leaving the listing

Cart and checkout

The drop-off zone in every e-commerce funnel:

  • Cart drawer or page: quantity adjustment, remove, updated totals
  • Cart persistence: logged-in carts to the database, guest carts to localStorage
  • Multi-step or one-page checkout: information, shipping, payment, review, confirmation
  • Guest checkout: don't force account creation
  • Address book: for returning customers
  • Shipping calculator: live rates or flat rates
  • Tax calculation: by destination
  • Payment: Stripe, Apple Pay, Google Pay
  • Order confirmation: with email send

Customer accounts

Logged-in shoppers need:

  • Order history: status, tracking links, order items
  • Re-order: for repeat purchases
  • Saved addresses
  • Saved payment methods
  • Wishlist
  • Account settings: email, password, marketing preferences
  • Returns and refunds: request flow

Admin panel

Where the operator manages the store:

  • Order management: list, filter, search, update status, refund
  • Product management: create, edit, archive, bulk operations
  • Inventory tracking: current stock, low-stock alerts, manual adjustments
  • Customer management: list, view orders, customer lifetime value
  • Discount codes: percentage off, dollar off, free shipping, BOGO
  • Reports: revenue, top products, conversion rate, average order value

Email workflows

Transactional and marketing emails:

  • Order confirmation: immediately on purchase
  • Shipping notification: when status changes to "shipped"
  • Delivery confirmation: when delivered
  • Abandoned cart: after 24 hours of inactivity
  • Review request: 7-14 days after delivery
  • Welcome series: for new customers
  • Replenishment reminders: for consumables

Tech stack decisions

  • Payments: Stripe (default), Razorpay (India-first), Adyen (enterprise)
  • Search: Algolia, Typesense, Meilisearch, or Postgres tsvector for under 5,000 products
  • Image handling: Cloudinary, imgix, or self-hosted via Cloudflare Images
  • Email: Resend + React Email for transactional, Klaviyo or Customer.io for marketing
  • Inventory: database-tracked for single-channel, system of record for multi-channel
  • Shipping rates: Shippo, EasyPost, or flat rates
  • Tax: TaxJar, Avalara, or Stripe Tax
  • Database: Postgres with Drizzle or Prisma
  • Cache: Next.js ISR for product pages, Redis or Vercel KV for cart sessions

Build path 1: From scratch (16 to 20 weeks)

The realistic order:

  1. Foundation: Next.js, auth, database schema
  2. Storefront: category pages, product detail, image gallery, variant picker
  3. Cart: cart drawer, persistence, quantity adjustments
  4. Checkout: multi-step or one-page flow, address handling, shipping calculator, tax calculation, Stripe integration
  5. Customer accounts: order history, profile, addresses
  6. Admin panel: order management, product management, inventory
  7. Email workflows: transactional first, abandoned cart second
  8. Discounts and promotions: code redemption, automatic discounts, BOGO logic
  9. Polish: search and filters, related products, reviews

Gotchas:

  • Build variants from day one, even if you only have one variant per product initially.
  • Always offer guest checkout to avoid dropping 20-30% of conversions.
  • Use a rate-calculator pattern for shipping, even for flat rates.
  • Spend a week on cart UX to ensure persistence, immediate updates, and shipping estimates.
  • Wire tax calculation from day one, even if the rate is zero in most jurisdictions.
  • Build the admin panel in parallel with the storefront, not after.

Build path 2: Using an e-commerce kit (2 to 3 weeks)

A pre-built kit like the E-commerce Kit provides:

  • Storefront with category, product, search, and detail pages
  • Product variant picker with image, price, and inventory updates
  • Cart drawer with guest and logged-in persistence
  • Multi-step checkout
  • Customer account with order history, addresses, wishlist
  • Admin panel with order management, product CRUD, inventory tracking, discount codes
  • Transactional email templates

What remains:

  • Wire your payment provider (Stripe webhook handling)
  • Connect database, replace seed products with real catalog
  • Wire shipping rate provider or configure flat rates
  • Configure tax (Stripe Tax for US, TaxJar/Avalara for international)
  • Customize email templates

Step-by-step from the kit

  1. Setup, brand, database: schema migration, import product catalog
  2. Auth: wire auth provider, configure guest checkout
  3. Stripe: set up products and prices, wire webhook handler
  4. Shipping: wire live rates or configure flat-rate zones
  5. Tax: configure Stripe Tax or TaxJar/Avalara
  6. Email: connect Resend, customize templates
  7. Admin training and content: load product photos, configure discount codes
  8. Deploy and beta: Vercel deploy, custom domain, soft launch

Common pitfalls

  • Skipping variants: leads to a data model rewrite when you add more variants.
  • Forcing account creation: drops conversion by 20-30%.
  • Hardcoding shipping rates: requires code changes when expanding to new countries.
  • Underbuilding the cart: loses sales if it doesn't persist or update totals immediately.
  • Skipping tax: causes issues when launching in jurisdictions with sales tax.
  • Building the admin last: leaves you unable to process orders without engineering help on launch day.
  • Ignoring abandoned cart emails: leaves 10-20% of revenue on the table.
  • Slow product images: largest LCP contributor; use srcsets, WebP/AVIF, lazy-loading.

This is a shorter version of a guide I wrote at Frontkit Studio. The full post has the complete walkthrough.

Top comments (0)