logo
Try for free
  • Product
  • Solutions
  • Developers
  • Resources
  • AI
  • Pricing
  • Log in
  • Create a store
  • Product

  • AI
  • Pricing
  • Try for free
  • Log In
  • Merchandising

  • Operations

  • Building

  • Integrations

  • Products

    Powerful modeling and versatile presentation of your entire catalog.

  • Subscriptions

    Sell recurring physical and virtual products alongside one-time offerings.

  • Discounts

    Get the sale with coupons, BXGY promotions, and automatic discounts.

  • Wholesale

    Sell B2B like it's DTC, along with volume pricing, customer groups, and invoicing.

  • Content

    Manage all your products content through the admin dashboard.

  • Users

    Multi-store admin accounts and role-based permission controls.

  • Customers

    Manage customer info, generate reports, and see buyer activity.

  • Orders

    Edit orders anytime and get the right information for smooth fulfillment.

  • Fulfillment

    Ship from multiple locations, track inventory, and split shipments.

  • Reporting

    Monitor your store's performance to ensure you have visibility across the business.

  • Storefronts

    Swell storefronts are fully customizable, allowing you to create just the right experience.

  • Checkouts

    Use our hosted checkout, integrate with a partner, or build a custom flow.

  • Payments

    Connect multiple gateways simultaneously, store cards, and split payments.

  • Internationalization

    Go global with region-specific languages, pricing, and payment methods.

No-code integrations

Connect with 40+ services for marketing, payments, fulfillment, automation, and more.

See all integrations →

Use Cases

  • Direct-to-consumer

    Tell your story and give customers a unique shopping experience

  • Subscriptions

    Sell personalized subscription bundles, memberships, and one-time items together

  • B2B/B2C

    Support retail and wholesale customers from one catalog and dashboard

  • Marketplaces

    Create a B2B or B2C marketplace with multi-vendor carts and split payouts

Customer Stories

  • Spinn Coffee

    A coffee revolution sparked by a connected machine and marketplace

  • Smashing magazine

    Global tax and shipping for complex product bundles

  • Infinitas Learning

    Delievering leading educational experiences in Europe

All customer stories →

Documentation

  • Quickstart

  • Backend API reference

  • Frontend API reference

  • Guides

  • Core concepts

  • Storefronts

  • Headless commerce

Community

  • GitHub

  • Discussion forum

  • Changelog

  • API status

Resources

  • Help Center

    The latest industry news, updates and info.

  • Customer stories

    Learn how our customers are making big changes.

  • Become a partner

    For agencies creating innovative commerce experiences.

Latest blog posts

  • deep-dive-app-functions
    Nov 06, 2025

    Build smarter workflows with App Functions

  • storefronts-v2-and-the-future-of-swell-apps
    Oct 22, 2025

    Storefronts V2 and the future of Swell Apps

  • Changelog

  • API Status

  • Contact us

  • Swell Merch

Blog

How to Add Ecommerce to a Lovable App in 2026

Compare five ways to sell from a Lovable app, from Shopify and Stripe to a headless backend, then follow a prompt-by-prompt swell-js setup with key safety rules.

Swell Team | October 23, 2026
Close-up of HTML code on a dark laptop screen.

To add ecommerce to a Lovable app, pick where your catalog, cart and orders will live, then prompt Lovable to wire your app to that system. You have five realistic routes: Lovable's Shopify integration, Lovable's built-in payments or your own connected Stripe account, a plain Stripe Payment Link, a headless commerce backend such as Swell called through `swell-js`, or your own tables in Supabase with Stripe Checkout on top.

The right route depends on what you sell. Digital products and software subscriptions fit Lovable's payment integrations. Physical goods with variants, shipping, tax and order fulfillment need a commerce backend, either Shopify through Lovable's integration or a headless platform you call from the generated code.

This guide is for people who build by prompt. It covers what Lovable actually generates, where keys belong, which documented `swell-js` calls to ask for, and what tends to break once real customers show up.

Key Takeaways

  • Lovable's own docs point physical-product sellers to its Shopify integration and position built-in payments for digital products, SaaS and memberships.
  • Lovable's Stripe integration runs through edge functions with the secret key stored as a backend secret, so it needs Lovable Cloud or a connected Supabase project.
  • A headless backend like Swell keeps catalog, cart, tax rules, subscriptions and orders outside your app. Your Lovable code only needs a store ID and a public key, plus a redirect to the cart's `checkout_url`.
  • Only public or publishable keys belong in generated frontend code. Secret keys go in Lovable's Secrets or Supabase secrets and are used from edge functions only.
  • A self-built Supabase and Stripe cart has no tax calculation, inventory logic or order admin until you build or buy each one.
  • Since May 13, 2026, new Lovable projects use TanStack Start with server rendering, which changes how cart sessions must be handled on the server.

What Lovable generates, and why it matters for a store

Lovable writes real application code that you steer by prompt. According to Lovable's TanStack Start upgrade guide, TanStack Start became the default for new projects on May 13, 2026 (and for new Enterprise projects on June 22, 2026). Older projects use React and Vite, where the browser builds the page with JavaScript. TanStack Start renders pages into HTML on the server first.

For the backend, Lovable defaults to Lovable Cloud, and you can connect your own Supabase project instead. The Supabase integration docs describe what you get: a database Lovable designs from plain-language descriptions, Supabase Auth, storage, realtime updates, and edge functions for payments, emails and external API calls. Secrets you enter through Lovable's secure input are stored in the backend, where edge functions can read them, and "never appear in your app's code."

That split shapes every commerce decision below. Anything that runs in the browser is public. Anything that needs a secret key has to run in an edge function or server function. When you prompt for a store, you are really choosing which pieces of commerce logic run where, and which vendor holds the data.

Five ways to sell from a Lovable app

Each route below is described from a Lovable builder's point of view: what Lovable sets up, where keys live, and what you still have to build for catalog, cart, tax, subscriptions and order admin.

1. Lovable's Shopify integration

Lovable can create a new Shopify store for you or connect one you already own. Per Lovable's Shopify integration docs, a new store starts as a sandbox (development) store at no Shopify cost. You must claim it within 30 days or Shopify removes it. Claiming starts a separate 120-day free trial of a Shopify subscription, after which you need a paid Shopify plan, billed by Shopify and separate from Lovable.

From the Lovable chat you can create, update and delete products, change prices and descriptions, create collections and add discount codes. The docs also note that projects with a connected Shopify store cannot be remixed, and that the Shopify session can expire after up to 24 hours, which means reconnecting.

What you get: a full catalog, cart and Shopify checkout, with order management in Shopify Admin. What to watch: you are now running a Shopify store with a custom frontend, so Shopify's plan costs and platform rules apply.

2. Lovable payments or your own Stripe account

Lovable offers built-in payments powered by Paddle or Stripe. The payments docs list the eligible use cases as SaaS subscription tiers, premium features and one-time purchases in consumer apps, memberships, digital downloads and developer tools. For physical products, the same page says to use the Shopify integration. Built-in payments require a paid Lovable plan. Paddle acts as merchant of record and handles tax compliance, invoicing and receipts, at 5.0% + 50¢ per transaction per Lovable's docs. Stripe uses its standard pay-as-you-go rates.

You can also connect your own Stripe account, including on the Free plan. This needs Lovable Cloud or a self-managed Supabase project. Lovable stores the key as a backend secret named `STRIPE_SECRET_KEY` and generates edge functions that create checkouts, plus optional products and prices, subscription status checks, a customer portal and webhooks. Subscriptions require user authentication so payments can be matched to accounts. You cannot run this alongside built-in payments at the same time.

What you get: payment collection and, with Stripe Billing, subscriptions. What you do not get: a product catalog with variants, a cart, shipping rates, inventory or an order admin built for fulfillment.

3. A Stripe Payment Link

A Stripe Payment Link needs no backend in Lovable: point a "Buy" button at the link, but the sale exists only in Stripe until you add a webhook edge function. See ways to accept payments.

4. A headless commerce backend called from your code

A headless platform holds the catalog, cart, checkout, tax rules, subscriptions and orders, and exposes them through an API your frontend calls. With Swell, the browser-safe layer is the Frontend API and its JavaScript SDK, `swell-js`. Swell's docs describe it as authorized with a public key and session token, "so it's safe to use in any context." Your Lovable app renders the product pages and cart UI. Swell's hosted checkout takes payment.

What you get: catalog with variants, cart, hosted checkout, tax settings, subscription purchase options and an order admin, without storing any of it in Supabase. What you build: the storefront pages and cart UI, which is exactly the part Lovable is good at generating.

5. Rolling your own with Supabase and Stripe Checkout

You can ask Lovable to create `products`, `carts` and `orders` tables in Supabase, then add an edge function that creates a Stripe Checkout Session from the cart and a webhook function that writes the order after payment. It works for a small catalog, and every piece lives in your project.

The cost is that you now own everything a commerce platform normally handles: price integrity (the edge function must look up prices server-side, never trust prices sent from the browser), stock decrements, row-level security on every table, tax, shipping rates, refunds and an admin screen for orders. Each one is another round of prompts, review and testing.

How the routes compare

  • Catalog with variants: Shopify and a headless backend include one. Stripe models products and prices, so variants are separate products or prices you manage yourself. Roll-your-own means you design it.
  • Cart: Shopify and a headless backend include one. Lovable's Stripe integration and Payment Links do not. Roll-your-own means Supabase tables.
  • Tax: Paddle handles it as merchant of record. Stripe needs Stripe Tax enabled. Swell applies tax rules from the store's tax settings, and Shopify handles tax inside its own platform. Roll-your-own has none until you add it.
  • Subscriptions: Lovable's payment integrations, Payment Links, Stripe Checkout and Swell purchase options all support them in some form.
  • Order admin: Shopify Admin and the Swell dashboard are built for fulfillment. Stripe and Paddle dashboards show payments, not pick lists.

Step by step: connect a Lovable app to Swell

The steps below use only calls documented on developers.swell.is. Each step includes a prompt you can paste into Lovable. Adjust names to match your project.

Before you start, create a Swell store and turn on its test environment. Add a few products in the dashboard, then copy your store ID and a public key from Developer > API keys. Public keys start with `pk_`, and test keys start with `pk_test_`.

Step 1: Install swell-js and initialize it

The Swell.js setup docs show the install (`npm install swell-js`) and initialization: `swell.init('<store-id>', '<public_key>')`. An optional third argument, `{ useCamelCase: true }`, converts the API's snake_case fields to camelCase.

Store the store ID and public key as public configuration. In a React and Vite project, that means `VITE_` environment variables. TanStack Start projects work the same way: per the TanStack Start environment variables guide, client code can only read variables with the build tool's public prefix, which is `VITE_` for Vite. Vite's docs state that VITE_ variables are exposed in client-side source code, which is acceptable for a public key and never acceptable for a secret key.

Prompt: "Install the swell-js package. Create `src/lib/swell.ts` that imports swell from 'swell-js' and calls `swell.init()` with the store ID and public key read from public environment variables. Do not use any secret key anywhere in the frontend. Export the initialized client."

Step 2: Build a product listing page

`swell.products.list()` returns products with offset pagination through `limit` and `page`, and the products docs cap `limit` at 100 per page. Add `category` with a slug or ID to filter, `search` for full-text search across ID, name, slug and SKU, or `expand: ['variants']` to include active variants.

Prompt: "Create a /shop page that calls `swell.products.list({ limit: 24, page })` and renders a grid of product cards with image, name and price. Add Next and Previous buttons that change the page number. Show a loading state and an empty state."

Step 3: Build a product detail page with variants

`swell.products.get()` accepts a slug or an ID, so you can use clean URLs like `/products/blue-shoes`. For products with options, `swell.products.variation(product, { Size: 'Medium', Color: 'Turquoise' })` returns the product merged with the matching variant's `price`, `sale_price`, `orig_price` and `stock_status`. It runs on the product object you already fetched, so it needs no extra request.

Prompt: "Create a /products/:slug route that loads the product with `swell.products.get(slug)`. Render an option picker for each product option. When the selection changes, call `swell.products.variation(product, selectedOptions)` and show the resulting price and stock status. Disable the Add to cart button if the variant is out of stock."

Step 4: Add to cart and build the cart drawer

The Swell.js carts docs cover the cart methods. `swell.cart.addItem({ product_id, quantity, options })` adds an item and returns the updated cart. Options can be an object of name/value pairs. `swell.cart.get()` returns the session's cart, or `null` if nothing has been added yet. `swell.cart.updateItem(itemId, { quantity })` and `swell.cart.removeItem(itemId)` change line items.

There is no cart ID for you to track. In the browser, Swell.js stores the visitor's session token in a `swell-session` cookie and sends it with later requests, per the Swell.js basic usage docs.

Prompt: "Add a cart drawer. On Add to cart, call `swell.cart.addItem({ product_id: product.id, quantity, options: selectedOptions })`, store the returned cart in a React context and open the drawer. On page load, call `swell.cart.get()` and treat a null result as an empty cart. In the drawer, use `swell.cart.updateItem(item.id, { quantity })` for the quantity stepper and `swell.cart.removeItem(item.id)` for Remove. If a response contains an `errors` object, show the messages."

Step 5: Send the buyer to hosted checkout

Every Swell cart has a `checkout_url` field. The cart model reference says it is "set automatically when the cart has at least `items`, `shipping`, or `billing` details set." If you initialized with `useCamelCase`, read it as `checkoutUrl`.

Prompt: "Add a Checkout button to the cart drawer. When clicked, read `checkout_url` from the current cart and redirect the browser to it with `window.location.href`. Hide the button when the cart is empty."

Swell's payments overview says the hosted checkout is included with all stores, works for subscriptions and one-time purchases, and supports credit card, PayPal, Apple Pay, Amazon Pay, Google Pay and Klarna through supported gateways. Payment details never pass through your Lovable app.

Step 6: Handle server rendering on newer Lovable projects

If your project uses TanStack Start, some code runs on the server before the page reaches the browser. The basic usage docs warn that on a server there is no cookie store, so each request starts a new session and an empty cart unless you supply one. They also say to use `swell.create()` for per-request clients rather than the shared `swell.init()` client, "so one visitor's session can't leak into another's request."

The simplest fix is to keep cart calls in the browser and let the server render only catalog data.

Prompt: "Make sure all `swell.cart` calls run only in the browser, inside client components or effects, never during server rendering. Product listing and product detail data can load on the server. If any server code needs a visitor's cart, create a per-request client with `swell.create()` instead of using the shared client."

Step 7: Test, then switch keys

Place test orders against the test environment with your gateway in test mode. When you go live, Swell's going-live guide says swapping keys is the actual cutover: replace `pk_test_` with `pk_live_` in your storefront configuration, connect the gateway with live credentials, and recreate settings in the live environment, since test and live have separate databases.

Security: what AI-generated code gets wrong with keys

AI builders make it easy to paste a key into a chat and watch it work. That convenience is where most commerce leaks start. A few rules cover nearly every case.

Know which keys are public. Swell's quickstart says public keys (`pk_`) are safe in browsers and storefronts, while secret keys (`sk_`) "grant full access to the Backend API" and must stay on the server. Stripe's API keys docs say only publishable keys are safe to expose. Supabase's API keys guide warns that a secret key "bypasses every Row Level Security policy you have."

Never paste a secret into the chat. Lovable's Stripe docs say to enter the key only in the Connect Stripe form, never as a chat message. Lovable's security features detect API keys pasted into chat and guide you to store them in Secrets, and they also state that "API keys and other secrets cannot be stored safely in client-side code."

Put Backend API calls in edge functions. If you need the Swell Backend API (to create products in bulk, read all orders, or adjust inventory), store the secret key as a Lovable or Supabase secret and call it only from an edge function. Prompt Lovable explicitly: "Read the Swell secret key from backend secrets inside an edge function. Never import it into frontend code."

Search the generated code. After any payments or commerce prompt, search the project for `sk_`, `sk_live`, `sk_test` and `service_role`. Check `.env` files and anything with a `VITE_` prefix. Lovable's quick security scan runs automatically when you open the publish dialog, but its docs also say the tools "cannot guarantee complete security."

Watch who can see the project. Per Lovable's project access docs, public remixing is off by default. If you turn it on, people can view your source code in their copy, so it must not contain keys or personal data. The stakes are real: Lovable's April 2026 incident report describes a regression between February 3 and April 20, 2026 that let chat history and source code of public projects be read by other users. Lovable says it has since made historically public projects private. If a secret key ever lands in chat history or code, rotate it.

Never trust prices from the browser. This applies mainly to the roll-your-own route. If an edge function creates a Stripe Checkout Session from cart data the browser sent, it must look up each price server-side. With Swell or Shopify, the platform computes the cart total and the hosted checkout charges it.

Reality check: taxes, subscriptions, fulfillment and cost

Taxes

A Supabase and Stripe cart you build yourself charges whatever total your code computes. It calculates no sales tax or VAT unless you enable Stripe Tax on your Checkout Sessions or Payment Links, or use a backend that applies tax rules. Paddle, as merchant of record, handles tax for Lovable's built-in Paddle payments. Swell's cart model applies tax rules from the store's tax settings, and stores can add a tax service through a tax extension app. Either way, calculating tax is separate from registering and filing. Our sales tax and VAT guide covers the obligations themselves.

Subscriptions

Most of these routes can sell recurring products, but they differ in where the subscription lives. Lovable's Stripe integration generates subscription checks and a customer portal tied to Lovable auth users. Payment Links can sell a subscription with no code. In Swell, subscriptions are a purchase option on a product, with plans that carry their own interval, price and optional trial. For physical subscriptions, invoices follow the billing schedule and orders follow the fulfillment schedule. With swell-js you add a subscription item by passing `purchase_option: { type: 'subscription' }` to `swell.cart.addItem()`, or `plan_id` inside that object to pick a specific plan. For billing intervals, dunning and the common setup mistakes, see our guide to setting up recurring billing.

Order notifications and fulfillment

A sale is not finished when the payment succeeds. Someone has to ship it, email the customer and record it. On the roll-your-own route, your Stripe webhook edge function is the only thing that turns a payment into an order row, so a failed or duplicated webhook means a missing or duplicate order. With Swell, orders are created by the platform and appear in the dashboard. If your app needs to react to them (to update a Supabase table or notify a fulfillment partner), Swell's webhook docs show how to configure a webhook under Developer > Webhooks for events such as `order.created`, pointed at an edge function URL. Swell disables a webhook automatically after 4 days of failed deliveries, so monitor it.

Hosted vs custom checkout

Every route in this guide sends the buyer to a hosted checkout: Shopify's, Stripe's, Paddle's or Swell's. That is the right default for a Lovable app because card data never touches your code. Swell also supports custom checkout flows built with Swell.js, but a custom checkout means owning payment UI, error states and load testing. Our post on checkout performance covers that tradeoff in detail.

What it costs

Lovable's built-in Paddle payments cost 5.0% + 50¢ per transaction per Lovable's docs, and built-in Stripe payments use Stripe's standard pay-as-you-go rates. A Shopify store created through Lovable becomes a paid Shopify plan after the trial.

Swell publishes its plans with overage rates that fall as you upgrade. Per the Swell pricing page, billed yearly: Starter is $29 per month with a $50K trailing-12-month revenue ceiling, Basic is $79 with a $250K ceiling, Standard is $299 with a $1M ceiling, and Unlimited is $2,250 with a $5M ceiling. Revenue beyond the ceiling is charged at 2%, 1.5%, 1% and 0.4% respectively. Merchants above $10M a year get custom pricing. Payment gateway processing fees apply on every route.

Which route to pick

  • Selling access to your app (SaaS tiers, premium features, memberships): use Lovable's built-in payments or connect your own Stripe account. This is the use case they were built for.
  • Selling one product or taking a deposit: a Stripe Payment Link is enough, and you can upgrade later.
  • Selling physical goods and happy to run Shopify: Lovable's Shopify integration is the most guided path, with product edits from chat.
  • Selling physical goods, subscriptions or a mixed catalog while keeping full control of the frontend: a headless backend like Swell keeps commerce data and checkout in a platform built for it, while Lovable generates the storefront. The steps above are the whole integration.
  • Learning, or selling a handful of items with no tax exposure: rolling your own in Supabase is fine, as long as you check the price-integrity and key rules.

Using Framer instead of Lovable? See our guide to adding an ecommerce store to a Framer website, where a plugin handles the wiring.

When you have outgrown the setup

A Lovable store can carry real revenue. These are signs the generated code, or the route you picked, has reached its limit:

  • You keep re-prompting the same bug. If every change to the cart or checkout breaks something else, bring in a developer to review the code before you add more.
  • Prices or stock disagree between places. That usually means the catalog lives in more than one system. Move to a single source of truth.
  • You need more than one storefront. A second brand, a wholesale site or a separate region is easier when the commerce backend is shared and each storefront is a thin frontend.
  • You need B2B pricing. Customer-group prices and quantity tiers belong in the commerce backend, not in frontend logic. Swell supports price rules by customer group and quantity on one-time purchases.
  • You sell across channels. Inventory shared across marketplaces, retail and your Lovable site needs a backend that tracks stock centrally.
  • Your order volume outgrows manual fulfillment. At that point you need webhooks feeding a fulfillment partner, monitored and retried, rather than a dashboard someone checks by hand.

None of these mean leaving Lovable. They mean the parts that hold money, stock and customer data should live in a commerce platform, and the Lovable app should stay a frontend.

FAQ

Can Lovable build an ecommerce store on its own?

Lovable can generate the storefront pages, cart UI and backend tables. For payments it uses integrations: Shopify for physical products, and Paddle or Stripe for digital products and subscriptions. The commerce logic behind a real store, including tax, inventory and order management, comes from whichever platform you connect.

Is it safe to put my Swell public key in a Lovable app?

Yes. Swell's docs say public keys are safe to use in browsers and storefronts with the Frontend API, which returns only data that has been made public. Never put a Swell secret key (`sk_`) in frontend code, the Lovable chat or a `VITE_` variable.

Do I need Supabase or Lovable Cloud to use Swell?

Not for a basic store. Product pages, the cart and the redirect to hosted checkout all use `swell-js` with a public key in the browser. You need Lovable Cloud or Supabase only when you call the Swell Backend API with a secret key, for example from an edge function that handles webhooks.

How does the buyer pay on the Swell route?

Your app redirects the buyer to the cart's `checkout_url`, which is set automatically once the cart has items. Swell's hosted checkout collects payment through your configured gateway and creates the order.

Can I sell subscriptions from a Lovable app?

Yes. Lovable's payment integrations, Stripe Payment Links and Swell all support recurring billing. With Swell, add `purchase_option: { type: 'subscription' }` when calling `swell.cart.addItem()` for a product that has subscription plans, and the hosted checkout handles the recurring payment setup.

Why is my Swell cart empty after a page reload?

Check where the cart call runs. In the browser, Swell.js keeps the session in a `swell-session` cookie, so the cart persists. If the call runs during server rendering, as it can in TanStack Start projects, there is no cookie and each request starts a new session. Keep cart calls in the browser or create a per-request client with `swell.create()`.

What does Lovable's Shopify integration cost?

The sandbox store is free. Once you claim it, you get a 120-day free trial of a Shopify subscription per Lovable's docs, and after that a paid Shopify plan, billed by Shopify separately from your Lovable plan.

Build your store on Swell

Headless commerce with a full API on every plan, native subscriptions and custom data models. Start a store and see how it fits your build.

Try Swell for freeTalk to us

Next-level commerce for everyone.

X.comGitHubLinkedIn

Subscribe to our newsletter for product updates and stories

Resources

Help CenterDeveloper CenterCommunityChangelogLearnSwell Merch

Use cases

SubscriptionsB2B WholesaleMarketplaceOmnichannelDirect-to-consumerEnterprise

Explore

FeaturesPricingIntegrationsCustomer stories

Developers

OverviewDocumentationGuidesStorefrontsHeadlessSwell Apps

Company

BlogAbout usPartnersContact us

© 2026 Swell. All rights reserved.

Privacy PolicyTerms of Service