Short answers about Medusa, also served as Markdown

Browse by topic

Reading this with an agent?

Every page in the knowledge base is also served as Markdown with frontmatter. Point your agent at the index, then fetch entries directly.

HTML/kb/headless-checkout/add-ecommerce-to-nextjs

How to add a cart and checkout to an existing Next.js site

To add a cart and checkout to an existing Next.js site and keep your own design, connect it to a commerce backend such as Medusa. Medusa runs as a separate Node.js app with PostgreSQL, which Medusa Cloud hosts from $29/month. Your Next.js app calls it through the @medusajs/js-sdk package for carts, shipping, Stripe payments, and orders.

Markdown/kb/headless-checkout/add-ecommerce-to-nextjs.md
---
title: "How to add a cart and checkout to an existing Next.js site"
description: "Add a cart and checkout to a Next.js site: Snipcart, Shopify Buy Button, Stripe Checkout, and Medusa compared, plus the Medusa steps with JS SDK code."
url: https://medusajs.com/kb/headless-checkout/add-ecommerce-to-nextjs
last_updated: 2026-10-29T06:55:50Z
topic: "headless-checkout"
type: "how-to"
applies_to: "Medusa v2.x"
related:
  - "https://medusajs.com/kb/headless-checkout/stripe-vs-commerce-backend.md"
  - "https://medusajs.com/kb/headless-checkout/custom-checkout-flow.md"
  - "https://medusajs.com/kb/build-vs-buy/what-is-headless-commerce.md"
  - "https://medusajs.com/kb/build-vs-buy/shopify-vs-custom-store.md"
  - "https://medusajs.com/kb/agentic-commerce/ecommerce-stack-for-ai-coding.md"
sources:
  - "https://docs.medusajs.com/resources/js-sdk"
  - "https://docs.medusajs.com/resources/storefront-development/checkout"
  - "https://docs.medusajs.com/resources/storefront-development/checkout/payment/stripe"
  - "https://docs.medusajs.com/resources/commerce-modules/payment/payment-provider/stripe"
  - "https://docs.medusajs.com/resources/storefront-development/publishable-api-keys"
  - "https://docs.medusajs.com/resources/nextjs-starter"
  - "https://docs.medusajs.com/learn/introduction/architecture"

Start from /kb/llms.txt, append .md to any path, or send Accept: text/markdown.