惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Hugging Face - Blog
Hugging Face - Blog
Stack Overflow Blog
Stack Overflow Blog
量子位
腾讯CDC
N
Netflix TechBlog - Medium
aimingoo的专栏
aimingoo的专栏
小众软件
小众软件
S
SegmentFault 最新的问题
A
About on SuperTechFans
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Tailwind CSS Blog
G
Google Developers Blog
U
Unit 42
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
雷峰网
雷峰网
罗磊的独立博客
Vercel News
Vercel News
L
LangChain Blog
V
V2EX
P
Proofpoint News Feed
M
MIT News - Artificial intelligence
博客园 - Franky
V
Visual Studio Blog
J
Java Code Geeks

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Build a Full eCommerce Store with Next.js + Cartvelly in ...
Milton Mahmu · 2026-04-27 · via DEV Community

No server setup. No backend code. Just paste an API link and start selling.

Introduction

Every time you build an eCommerce project for a client, you probably spend days setting up the backend — products, orders, payments, inventory, shipping. Then you do it all over again for the next client.

Cartvelly fixes this. It's a headless eCommerce CMS that gives you a fully managed backend via a simple REST API. You bring the frontend — React, Next.js, Vue, anything — and Cartvelly handles everything else.

In this tutorial, we'll build a working product listing page with cart and checkout using Next.js and Cartvelly's API.

Cartvelly has a free plan with no credit card required. Sign up at cartvelly.com to follow along.


What we'll build

A Next.js storefront that fetches and displays products from Cartvelly, supports a shopping cart, handles checkout via Stripe or PayPal, and tracks orders — all without writing a single line of backend code.


Step 1 — Set up your Cartvelly store

  1. Sign up at cartvelly.com and create your first store.
  2. Add a few products from the dashboard — name, price, images, and stock.
  3. Copy your API Key and Store ID from settings.

Step 2 — Create a Next.js project

npx create-next-app@latest my-store
cd my-store
npm install axios

Enter fullscreen mode Exit fullscreen mode

Create a .env.local file:

NEXT_PUBLIC_API_URL=https://client.cartvelly.com/api/stores
NEXT_PUBLIC_STORE_ID=your_store_id
NEXT_PUBLIC_API_KEY=your_api_key

Enter fullscreen mode Exit fullscreen mode


Step 3 — Fetch products from Cartvelly

Create a reusable API client:

// lib/cartvelly.js
import axios from "axios";

const client = axios.create({
  baseURL: process.env.NEXT_PUBLIC_API_URL,
  headers: {
    "x-api-key": process.env.NEXT_PUBLIC_API_KEY,
    "storeId": process.env.NEXT_PUBLIC_STORE_ID,
  },
});

export const getProducts = () => client.get("/products");
export const getProduct = (id) => client.get(`/products/${id}`);
export const getCategories = () => client.get("/categories");
export const getCoupon = (code) => client.get(`/coupons/code/${code}`);

Enter fullscreen mode Exit fullscreen mode


Step 4 — Build the product listing page

// pages/index.js
import { getProducts } from "../lib/cartvelly";

export async function getServerSideProps() {
  const { data } = await getProducts();
  return { props: { products: data } };
}

export default function Home({ products }) {
  return (
    <div className="grid">
      {products.map((product) => (
        <div key={product._id} className="card">
          <img src={product.images[0]} alt={product.name} />
          <h3>{product.name}</h3>
          <p>${product.price}</p>
          <button>Add to Cart</button>
        </div>
      ))}
    </div>
  );
}

Enter fullscreen mode Exit fullscreen mode


Step 5 — Create an order with payment

Cartvelly supports three payment methods out of the box: /orders, /payments/stripe, and /payments/paypal.

const handleCheckout = async (cartItems, billing) => {
  const orderRes = await axios.post(
    `${process.env.NEXT_PUBLIC_API_URL}/orders`,
    { items: cartItems, billing, paymentMethod: "stripe" },
    { headers: { "x-api-key": "...", "storeId": "..." } }
  );

  const stripeRes = await axios.post(
    `${process.env.NEXT_PUBLIC_API_URL}/payments/stripe`,
    { orderId: orderRes.data._id }
  );

  window.location.href = stripeRes.data.url;
};

Enter fullscreen mode Exit fullscreen mode


Step 6 — Track shipments

const { data } = await client.get(`/shipments/${trackingNumber}`);

Enter fullscreen mode Exit fullscreen mode


Full API reference at a glance

Method Endpoint Description
GET /products All products
GET /categories All categories
GET /collections Product collections
GET /sliders Homepage sliders
GET /coupons/code/:code Validate coupon
GET /shippingZones?country=usa Shipping rates
POST /orders Create order
POST /reviews Submit review
POST /subscribers Add subscriber

Why Cartvelly instead of building your own backend?

Building a custom eCommerce backend from scratch takes weeks — authentication, database design, payment integration, email automation, inventory tracking. Cartvelly gives you all of that instantly, so you can focus entirely on the frontend experience.

It works with any frontend framework, charges no transaction fees, and has a free plan to get started.


Conclusion

In this tutorial we connected a Next.js frontend to a fully featured eCommerce backend in minutes — products, payments, shipping, coupons — all via a simple REST API with no server setup required.

The free plan at cartvelly.com is a great way to try it out. If you build something with it, drop a link in the comments!

Found this useful? Follow for more eCommerce and Next.js tutorials.