Next.js commerce
The commerce backend for your Next.js store.
Flint runs the catalog, cart, checkout, and orders behind a Next.js App Router storefront. Server components read products with the typed Node SDK, server actions keep the cart as an order Flint prices, and buyers pay on Flint's hosted checkout or on a checkout page you build. Your Next.js app is the only thing you deploy: no commerce server, no order tables, no cart math.
3.79% + 35¢ on cards · no monthly fee · free sandbox · no credit card
import Image from "next/image";
import type { Product } from "@flintpay/node";
import { flint } from "@/lib/flint";
import { formatMoney } from "@/lib/money";
import { addToCart } from "./cart/actions";
export default async function Shop() {
// a server component: the key and the request stay on the server
const { data: products } = await flint.products.list({
category_handle: "brew-gear",
status: ["active"],
});
return (
<main>
{products.map((p) => <Card key={p.product_id} product={p} />)}
</main>
);
}
function Card({ product }: { product: Product }) {
const [image] = product.images;
const add = addToCart.bind(null, product.default_variant_id!);
return (
<article>
{image && (
<Image src={image.url} alt={image.alt ?? product.name}
width={image.width} height={image.height} />
)}
<h2>{product.name}</h2>
<p>{formatMoney(product.price_range?.min_unit_price_money)}</p>
<form action={add}>
<button>Add to bag</button>
</form>
</article>
);
}A server component. Products, prices, and image sizes come from Flint, and only HTML and variant IDs reach the browser.
no commerce server to deploy · no order tables in your database · 746 API operations under one key
01The split
Next.js renders the store. Flint runs it.
Your repo holds the pages, the components, and the content. Everything with a price on it lives on Flint, so the code you write is the code that makes the store look like yours.
app/
page.tsx flint.products.list
cart/
actions.ts flint.orders.create · addLineItems
page.tsx flint.orders.get
checkout/
actions.ts flint.checkoutSessions.create
api/flint/
route.ts flint.verifyWebhookAsync
lib/
flint.ts new Client() · import "server-only"
.env.local FLINT_API_KEY · FLINT_WEBHOOK_ENDPOINT_IDEvery file a Cedar & Stone storefront needs to sell. None of them is a schema, a migration, or an admin route.
You keep what makes it your store: the design, the copy, your CMS, search, and your own sign-in if you have one. Attach a signed-in buyer’s Flint customer to the cart’s order, and their saved cards and order history follow them into checkout. Build a headless storefront covers how the pieces connect.
What Flint runs behind them
The catalog: products, variants, options, categories, bundles, and the images Flint hosts.
GET /v1/productsThe cart, as an open order Flint prices from the catalog, with discounts and tax on it.
POST /v1/ordersCheckout, on Flint's hosted page or on a page you build, taking cards, Apple Pay, Google Pay, ACH debit, and Affirm.
POST /v1/checkout-sessionsThe receipt Flint emails when the order is paid, built from the order's own lines.
order.paidRefunds by line item, with the line's share of tax worked out for you.
POST /v1/refundsA buyer account with order history, tracking, returns, subscriptions, and saved cards.
account.withflintpay.comA dashboard with 20 sections, among them orders, products, inventory, promotions, and returns.
app.withflintpay.com02Build it
Five steps from create-next-app to a paid order.
Everything here runs on a free sandbox key. The code is server components, server actions, a route handler, and two environment variables, so it runs the same on Vercel, in a container, or on your laptop.
Create the Flint client on the server
lib/flint.ts · .env.localPut FLINT_API_KEY and FLINT_WEBHOOK_ENDPOINT_ID in .env.local without the NEXT_PUBLIC_ prefix, so Next.js keeps the API key out of every client bundle, and create the client in lib/flint.ts behind import "server-only".
lib/flint.tsimport "server-only"; import { Client } from "@flintpay/node"; export const flint = new Client({ baseUrl: "https://api.withflintpay.com", apiKey: process.env.FLINT_API_KEY!, });Flint has no publishable key. Every API key is a server credential, so no component ever needs one.
API keysProduction CORS allows only Flint's own origins. The browser talks to your Next.js server, and your server talks to Flint.
CORSA sandbox key and a live key call the same host with the same code. The key decides the environment.
flint_test_ · flint_live_Render the catalog in server components
GET /v1/productsRead products with flint.products.list in a server component. Each product comes with its prices and its images, hosted by Flint with the width and height next/image asks for.
app/page.tsximport Image from "next/image"; import type { Product } from "@flintpay/node"; import { flint } from "@/lib/flint"; import { formatMoney } from "@/lib/money"; import { addToCart } from "./cart/actions"; export default async function Shop() { // a server component: the key and the request stay on the server const { data: products } = await flint.products.list({ category_handle: "brew-gear", status: ["active"], }); return ( <main> {products.map((p) => <Card key={p.product_id} product={p} />)} </main> ); } function Card({ product }: { product: Product }) { const [image] = product.images; const add = addToCart.bind(null, product.default_variant_id!); return ( <article> {image && ( <Image src={image.url} alt={image.alt ?? product.name} width={image.width} height={image.height} /> )} <h2>{product.name}</h2> <p>{formatMoney(product.price_range?.min_unit_price_money)}</p> <form action={add}> <button>Add to bag</button> </form> </article> ); }localhost:3000What that server component renders: the brew-gear category, priced and pictured from the catalog. Flint hosts every image and returns its width and height, the two props
next/imageneeds. Images guideimages[].widthCategory handles never change, so a /collections/[handle] route maps to one filter.
category_handleEdit a product in the dashboard and Flint sends product.updated, which the webhook route turns into revalidatePath.
product.updatedKeep the cart as a Flint order
POST /v1/orders · POST /v1/orders/{order_id}/line-itemsAn Add to bag form calls a server action that creates an order from a variant ID, or adds a line to the open one, and keeps the order ID in an httpOnly cookie. Flint prices every line from the catalog.
app/cart/actions.ts"use server"; import { cookies } from "next/headers"; import { revalidatePath } from "next/cache"; import { flint } from "@/lib/flint"; export async function addToCart(variantId: string) { const jar = await cookies(); const cartId = jar.get("cart")?.value; const cart = cartId ? await flint.orders.get(cartId).catch(() => null) : null; // a variant, not a price: Flint copies the catalog's // name, price, and tax settings onto the line const line = { type: "variant", variant_id: variantId, quantity: "1" } as const; if (cart?.status === "open" && cart.payment_status === "unpaid") { await flint.orders.addLineItems(cart.order_id, { line_items: [line], }); } else { const order = await flint.orders.create({ line_items: [line] }); jar.set("cart", order.order_id, { httpOnly: true, secure: true, sameSite: "lax", }); } revalidatePath("/cart"); }the cart · ord_1kmn0aExample · open Whole-bean coffeeline_items[].subtotal_money $16.00 Ceramic dripperline_items[].subtotal_money $24.00 Filter papersline_items[].subtotal_money $9.00 Subtotalpricing_amounts.subtotal_money $49.00 Taxtax.status: requires_location at checkout The bag before checkout. With automatic tax on, the order waits for a buyer location, and hosted checkout asks for one. A catalog line rejects a name, price, or tax setting sent with it, so a total edited in DevTools never reaches Flint.
NOT_ALLOWEDEvery write returns the order re-priced: its lines, discounts, tax, and balance due.
pricing_amountsPromotion codes apply to the same order, and a preview shows what a code would do before the buyer commits.
POST /v1/discount-previewsSend the buyer to hosted checkout
POST /v1/checkout-sessionsA checkout server action creates a checkout session for the cart's order and calls redirect() with its URL. Flint's hosted checkout collects the address and the payment.
app/checkout/actions.ts"use server"; import { cookies } from "next/headers"; import { redirect } from "next/navigation"; import { flint } from "@/lib/flint"; export async function checkout() { const orderId = (await cookies()).get("cart")?.value; if (!orderId) redirect("/cart"); const session = await flint.checkoutSessions.create( { type: "order", order_id: orderId, redirects: { // a sandbox accepts http://localhost on any port success_url: "http://localhost:3000/thanks", cancel_url: "http://localhost:3000/cart", }, }, // a double click gets the same session back, not a second one { idempotencyKey: `checkout-${orderId}` }, ); redirect(session.url!); }The cart page's Check out button is a form whose action is this function. There is no payment form to build and no SDK in the client bundle.
Change the bag after the session opens and the session stays open. Flint re-prices the order, and the buyer approves the new total before paying.
order.updatedA signed-in buyer's customer on the order brings their saved cards into checkout, and the paid order into their account.
customer_idIn a sandbox, success and cancel URLs can point at http://localhost on any port.
redirectsA session expires after 24 hours by default, and an expired link shows a notice, never a payment form.
expires_atFulfill from a webhook route and test it on localhost
app/api/flint/route.ts · flint listenVerify the raw body with flint.verifyWebhookAsync and your endpoint's ID, and fulfill on order.paid. Locally, flint listen forwards sandbox events as Flint-signed JWT deliveries and prints the endpoint ID. Before deploying, register an endpoint with POST /v1/webhook-endpoints and use its ID.
app/api/flint/route.ts// JWT receiver: Flint signs each delivery as a JWT with the endpoint's ID as // the audience. Locally, flint listen prints the whep_ ID. Before deploying, // POST /v1/webhook-endpoints with // {"url":"https://example.com/api/flint","enabled_events":["order.paid","refund.succeeded","product.updated","product_variant.updated"]} // and set FLINT_WEBHOOK_ENDPOINT_ID to the returned id. import { revalidatePath } from "next/cache"; import { flint } from "@/lib/flint"; type FlintEvent = { event_type: string; data: { object: { order_id?: string } }; }; export async function POST(request: Request) { // route handlers don't parse the body: these are the signed bytes const rawBody = new Uint8Array(await request.arrayBuffer()); // throws on a bad signature, the wrong audience, or an expired token const { event } = await flint.verifyWebhookAsync(rawBody, request.headers, { endpointIds: [process.env.FLINT_WEBHOOK_ENDPOINT_ID!], }); const { event_type, data } = event as FlintEvent; if (event_type === "order.paid") { const order = await flint.orders.get(data.object.order_id!); // fulfill order.line_items, once per webhook-id header } if (event_type.startsWith("product")) { // a dashboard edit re-renders the shop on its next visit revalidatePath("/"); } return new Response(null, { status: 204 }); }The success redirect is for the buyer; this route is the confirmation, because a buyer can close the tab before the redirect loads.
flint listen --forward-to http://localhost:3000/api/flintPay the test order with
4242 4242 4242 4242and watch the route fire. CLI guide →verifyWebhookAsync checks the JWT's issuer, audience, lifetime, and body hash against the raw bytes, and throws on a mismatch.
verifyWebhookAsyncA delivery counts once your route answers 2xx within 10 seconds. A failure retries with backoff, up to 9 attempts over about three days.
retriesEvery retry carries the same id, so processing each event once is one lookup.
webhook-idOn the wire
- Authorization
- Flint-Webhook-Endpoint-Id
- webhook-id
- webhook-timestamp
Events the route branches on
- order.paid
- refund.succeeded
- product.updated
- product_variant.updated
Coming from a Stripe tutorial? The post on what Next.js and Stripe tutorials leave out walks the unpaid sessions, duplicate fulfillment, client-set prices, and orders table that production adds. On Flint the order exists before the payment, so the price comes from the catalog and the webhook points at a record you never had to build.
03Checkout
Hosted, branded, or your own page.
Start on Flint's hosted checkout. Move it to your own domain in your colors when the store has a brand, or build the checkout page yourself on a headless session. The cart, the order, and the webhook route stay the same in all three.
POST /v1/checkout-sessions{
"type": "order",
"order_id": "ord_1kmn0aExample",
"surface": "headless"
}Checkout, payment links, and invoices under your business name. Nothing to build.
Your colors, fonts, and logo, on your domain as an add-on. The buyer account matches.
Your page, with no Flint mark. Stripe renders the card fields, and Flint computes the total and takes the payment.
Hosted checkout takes cards, Apple Pay, Google Pay, ACH debit, and Affirm, offers returning buyers their saved cards, and takes your promotion codes.
checkout.withflintpay.comYour colors, fonts, corners, and logo on your own domain. The custom domain add-on is $15 a month for one checkout and one account hostname.
POST /v1/custom-domainsOn a page you build, Stripe Elements renders the card fields, and card details never touch your server or Flint's.
surface: headlessThe browser calls your route handlers, never Flint, and the checkout credential stays on your server.
checkout_auth_tokenThe headless version, in Next.js. Flint’s example storefront builds Cedar & Stone on the Next.js 16 App Router with a headless checkout: delivery or pickup, discount codes, gift cards, tips, saved cards, wallets, ACH debit, Affirm, and subscription signup. Server actions run the store’s forms, and route handlers under app/checkout relay each checkout call to Flint.
Read the example on GitHub · Build your own checkout · Flint checkout
04After the sale
Receipts, accounts, and refunds are already running.
The first paid order arrives with a receipt in the buyer's inbox, an account they can sign in to, and a back office for you. None of it is a route in your app.
A receipt Flint emails when the order is paid, built from its lines. Send your own instead with one setting.
customer_email_deliveryA buyer account with orders, tracking, returns, subscriptions, and saved cards. It replaces app/account and the sign-in in front of it. Customer accounts guide
account.withflintpay.comA dashboard with 20 sections, among them orders, products, inventory, promotions, returns, and balances. It replaces app/admin.
app.withflintpay.comThe next request is a call, not a migration.
Stores ask for the same things in the same order, and each one attaches to the order your cart already is. None of them touches your schema.
Refund one item
Name the line and the quantity. Flint works out the line's tax share and returns it to the original payment.
- POST /v1/refunds
- refund_type
Sell the beans by subscription
Each renewal is an order, so the webhook route that fulfills one sale fulfills every renewal too.
- POST /v1/subscription-plans
Run a weekend code
Codes and automatic promotions apply to the order by rules you set, and a preview shows the result before the buyer commits.
- POST /v1/promotions
- POST /v1/discount-previews
Stop overselling
When the buyer pays, Flint holds the stock per location, commits it if the payment succeeds, and releases it if the payment fails.
- POST /v1/inventory-items
Take returns
Returns run from a policy, with restocking fees, exchanges for another size, and a self-serve flow for buyers.
- POST /v1/returns
Sell gift cards
A gift card is a catalog product. Buyers spend up to 20 on one order at hosted checkout.
- gift_card_configuration
Read more on subscriptions, gift cards, and shipping, stock, and returns. The commerce API page tours the whole engine behind the same key.
05Compared
Next.js commerce backends, side by side.
Flint is a hosted commerce API, so your Next.js app is the only thing you deploy. The other common backends run the store on their own platform or hand you a commerce server to operate. Vercel archived its Next.js Commerce template on October 20, 2026, and moved development to Vercel Shop, which runs on Shopify.
| What you get | Flint commerce API | Vercel Shop on Shopify | Medusa, self-hosted or Cloud | Saleor, self-hosted or Cloud |
|---|---|---|---|---|
| What you deploy | Flint: Your Next.js app, with the commerce API hosted by Flint | Shopify: Your Next.js app, on a Shopify plan | Medusa: A Medusa server and worker with PostgreSQL and Redis, or a Medusa Cloud plan | Saleor: The open-source Saleor API, or a Saleor Cloud plan |
| How Next.js reads the store | Flint: REST through the typed @flintpay/node SDK, in server components and server actions | Shopify: The Storefront API, in GraphQL, through Shopify's Hydrogen SDK | Medusa: Medusa's API, with an optional Next.js Starter Storefront | Saleor: A GraphQL-only API, with a Next.js App Router storefront example |
| Where the buyer pays | Flint: Flint's hosted checkout, on your domain as an add-on, or your own page with Stripe Elements | Shopify: Shopify's web checkout | Medusa: Your checkout, through a provider such as Medusa's Stripe module, enabled per region | Saleor: Your checkout, through a payment app such as Saleor's Stripe app |
| What it costs | Flint: 3.79% + 35¢ per card payment, processing included, no monthly fee | Shopify: From $39 a month on Basic, billed monthly, plus 2% on payments through a provider other than Shopify Payments | Medusa: MIT-licensed core to host yourself, or Medusa Cloud from $29 a month | Saleor: BSD-licensed source to host yourself, or Saleor Cloud from $1,599 a month |
Shopify suits a merchant who wants Shopify’s admin and ecosystem around the store. Medusa and Saleor suit a team that wants the commerce server’s source, to change and to host. Flint is for the team that wants the store’s code in its Next.js repo and nothing else to run.
Each comparison in depth: Flint vs Shopify, Shopify Hydrogen alternatives, Flint vs Medusa, Saleor alternatives, and headless commerce platforms.
What comes with the key
Your repo keeps the storefront. Flint runs the store behind it.
Stripe processes every card · card data goes straight to Stripe · processing included in the rate · samples validated against the published OpenAPI spec at build time
06Start
Start in the sandbox, or start from the example.
Add a store to my Next.js App Router app with
Flint and @flintpay/node. Read products in a
server component. Keep the cart as a Flint order
whose ID lives in an httpOnly cookie, and add
lines by variant ID in a server action. Send the
buyer to a hosted checkout session with
redirect(), and verify webhooks in a route
handler that fulfills on order.paid. Keep
FLINT_API_KEY server-only.Or write it yourself: the five steps are the whole integration.
Install the SDK
Install the CLI
Or clone the Next.js example storefront, run its setup script against your sandbox key, and Cedar & Stone’s catalog, cart, and checkout run on your machine.
Then read these
- 01
- 02
- 03
- 04
- 05
- 06
Or run npm install -g @flintpay/cli && flint signup to create your account and a sandbox key from the terminal. CLI guide
Sources
Where each outside claim comes from.
Vercel archived the Next.js Commerce repository on October 20, 2026. The README marks the template deprecated, says development moved to vercel/shop, and names Shopify as the provider the repository ships with; other providers fork it and replace its Shopify file. vercel/commerce on GitHub
github.com · checked 2026-10-23Vercel Shop is a Shopify storefront on the Next.js 16 App Router. Its README says Shopify owns commerce: catalog, cart, checkout, customer accounts, predictive search, and policies come from Shopify through the Hydrogen SDK. vercel/shop on GitHub
github.com · checked 2026-10-23A cart's checkoutUrl redirects customers through Shopify's web checkout. The Storefront API is queried with GraphQL. Shopify: Manage a cart with the Storefront API
shopify.dev · checked 2026-10-23Billed monthly in the US, Basic is $39 a month, and third-party transaction fees on Basic are 2%. Shopify pricing
www.shopify.com · checked 2026-10-23A self-hosted Medusa deployment runs a PostgreSQL database, a Redis database, and the Medusa application in server mode and in worker mode, on a host with at least 2GB of RAM. Medusa docs: General deployment
docs.medusajs.com · checked 2026-10-23Medusa's core is MIT licensed, and create-medusa-app sets up the server and admin dashboard and optionally the Next.js Starter Storefront. medusajs/medusa on GitHub
github.com · checked 2026-10-23The Stripe provider is configured with a Stripe secret API key and a webhook secret, and has to be enabled in each region that offers it. Medusa docs: Stripe module provider
docs.medusajs.com · checked 2026-10-23Medusa Cloud's Develop plan starts at $29 a month. Medusa pricing
medusajs.com · checked 2026-10-23Saleor is a GraphQL-only, API-only commerce platform under the BSD-3-Clause license, with an open-source storefront example built on the Next.js App Router. saleor/saleor on GitHub
github.com · checked 2026-10-23Saleor takes Stripe payments through its Stripe app, a payment gateway integration. Saleor docs: Stripe app
docs.saleor.io · checked 2026-10-23Saleor Cloud's Select plan is $1,599 a month, for up to $200,000 of GMV a month. Saleor pricing
saleor.io · checked 2026-10-23Only environment variables prefixed with NEXT_PUBLIC_ are included in the client bundle, and importing server-only into a module makes a client import of it a build-time error. Next.js docs: Server and Client Components
nextjs.org · checked 2026-10-23
last reviewed 2026-10-23 · corrections: Flint Help
FAQ
Questions Next.js developers ask first.
Can I build a Next.js ecommerce store without Shopify?
Yes. Flint is a hosted commerce API for the store behind your Next.js app: the catalog, the cart as an order, checkout, payments, receipts, buyer accounts, and refunds. Server components read products with @flintpay/node, server actions add lines to the cart's order, and a checkout session sends the buyer to Flint's hosted checkout or powers a checkout page you build. There is no Shopify plan or theme to adopt, and no commerce server to deploy.
What happened to the Next.js Commerce template?
Vercel archived the vercel/commerce repository on October 20, 2026. Its README marks the template deprecated and says development moved to vercel/shop, Vercel’s Shopify storefront built with Next.js. To keep the same App Router patterns with Flint underneath, the catalog renders in server components, the cart runs on server actions, and webhooks land in a route handler. Flint’s example storefront on GitHub does exactly that in Next.js 16.
Do I need a database to run a Next.js store on Flint?
Not for the commerce. Products, carts, orders, payments, refunds, and order history live on Flint, and the cart's order ID fits in a cookie. Your database, if you have one, keeps what is yours: content, user accounts, and anything a webhook grants on order.paid.
Should checkout start in a server action or a route handler?
Use a server action when a form starts the purchase: the Check out button's form calls it, it creates the checkout session, and redirect() sends the buyer to Flint. Use a route handler when a client component needs JSON back, or when a checkout page you build relays its calls to Flint. Webhooks are always a route handler, because Flint is the caller.
Can I call Flint from a client component?
No. Flint has no publishable key, and production CORS allows only Flint's own origins, so every Flint call goes through a server component, a server action, or a route handler. The client component sends what the buyer chose, a variant ID and a quantity, and gets back rendered HTML or a checkout URL. The key stays out of the bundle, and the total stays out of reach of anyone editing JavaScript in a browser.
How do I verify Flint webhooks in the App Router?
Read the raw bytes with request.arrayBuffer(), then pass them, request.headers, and your endpoint's ID to flint.verifyWebhookAsync from @flintpay/node. It checks the JWT's signature, issuer, audience, lifetime, and body hash, and throws on a mismatch. New endpoints sign with a JWT by default, so there is no shared secret to store. Route handlers don't parse the body for you, so there is no body parser to turn off. Deduplicate on the webhook-id header, which stays the same on every retry.
How do I test Flint webhooks on localhost?
Run next dev, then flint listen --forward-to http://localhost:3000/api/flint. The CLI streams your sandbox's events and forwards each one as a Flint-signed JWT delivery, with no tunnel. It prints the whep_ endpoint ID of a sandbox endpoint it creates and reuses; set it as FLINT_WEBHOOK_ENDPOINT_ID locally. In production, register an endpoint with POST /v1/webhook-endpoints and use its ID, so the same route runs in both places.
Does a Flint store work on Vercel?
Yes. The integration is server components, server actions, route handlers, and two environment variables, which every Next.js host runs, serverless or not. A webhook delivery that fails is retried with backoff, up to 9 attempts over about three days, so a cold start or a bad deploy doesn't lose a sale.
Can v0, Claude Code, or Cursor build this?
Yes. v0 generates Next.js, and Claude Code and Cursor work in your repo. Connect the Flint docs MCP server or give the agent SKILL.md, and it works from live endpoint schemas instead of memory. There is little to get wrong: a client in lib/flint.ts, two server actions, and one webhook route, with prices, totals, and tax computed on Flint’s side.
What does Flint cost for a Next.js store?
Cards cost 3.79% + 35¢, with no monthly fee, and the card processing underneath is included. Automatic sales tax adds 0.50% on payments that carry tax, subscription and invoice payments add 0.40%, and checkout and the buyer account on your own domain cost $15 a month. The sandbox is free, with no credit card. Pricing has every rate.
Put your Next.js store on Flint.
Free sandbox, no credit card. Your app renders the store, and Flint prices it, takes the payment, and keeps every order.
Or run npm install -g @flintpay/cli && flint signup to create your account and a sandbox key from the terminal. CLI guide
app/cart/actions.ts · the first file you write



