Skip to main content
RapidDev - Software Development Agency
lovable-integrationsEdge Function Integration

How to Integrate Lovable with WooCommerce

To integrate WooCommerce with Lovable, create a Supabase Edge Function that proxies your WooCommerce REST API calls using Consumer Key and Consumer Secret credentials stored in Cloud Secrets. This lets you build a modern React storefront in Lovable powered by your existing WooCommerce product catalog, cart, and checkout — without exposing your WordPress credentials in frontend code.

What you'll learn

  • How to generate WooCommerce REST API credentials from your WordPress admin panel
  • How to store WooCommerce Consumer Key and Secret securely in Lovable Cloud Secrets
  • How to write a Supabase Edge Function that proxies WooCommerce API calls on Deno
  • How to fetch products, categories, and cart data from WooCommerce in your React components
  • How to handle WooCommerce authentication and CORS in a Lovable storefront
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Intermediate14 min read45 minutesE-commerceMarch 2026RapidDev Engineering Team
TL;DR

To integrate WooCommerce with Lovable, create a Supabase Edge Function that proxies your WooCommerce REST API calls using Consumer Key and Consumer Secret credentials stored in Cloud Secrets. This lets you build a modern React storefront in Lovable powered by your existing WooCommerce product catalog, cart, and checkout — without exposing your WordPress credentials in frontend code.

Build a Modern React Storefront for Your WooCommerce Store

WooCommerce powers millions of online stores, but its default WordPress theme can feel slow, hard to customize, and disconnected from modern frontend tooling. With Lovable, you can build a blazing-fast React storefront — custom design, smooth UX, Tailwind CSS styling — while keeping all your products, inventory, orders, and customer data in WooCommerce where your team already manages them.

The integration follows Lovable's standard pattern for authenticated APIs: all WooCommerce REST API calls route through a Supabase Edge Function running on Deno. Your WooCommerce Consumer Key and Consumer Secret are stored as encrypted secrets in the Cloud tab, never touching the browser. The Edge Function handles Basic Auth encoding, forwards requests to your WordPress site's REST API endpoint (typically https://yourstore.com/wp-json/wc/v3/), and returns JSON data to your React components.

This is ideal for teams who have an existing WooCommerce catalog with products, pricing, and inventory already configured, but want a modern customer-facing frontend. You keep your WordPress admin for store operations and give customers a fast, branded React experience built in Lovable.

Integration method

Edge Function Integration

WooCommerce integration in Lovable works by creating Supabase Edge Functions that proxy requests to your WordPress site's WooCommerce REST API. Your WooCommerce Consumer Key and Consumer Secret are stored encrypted in Cloud Secrets and accessed via Deno.env.get() inside the Edge Function, never exposed to the browser. The React frontend in Lovable calls the Edge Function endpoint, which forwards the request to your WooCommerce store and returns product, cart, and order data.

Prerequisites

  • A live WordPress site with WooCommerce installed and products configured
  • WordPress admin access to generate WooCommerce REST API keys
  • Pretty Permalinks enabled in WordPress (Settings → Permalinks → Post name) — required for the REST API to function
  • A Lovable project with Lovable Cloud enabled (the default for all new projects)
  • Your WordPress site must be on HTTPS — WooCommerce REST API blocks non-SSL requests by default

Step-by-step guide

1

Generate WooCommerce REST API keys

Open your WordPress admin panel and navigate to WooCommerce → Settings → Advanced → REST API. Click the 'Add key' button to generate a new API key. Fill in the Description field with something memorable like 'Lovable Storefront' so you can identify it later. Set the User field to your admin WordPress user account. Set Permissions to 'Read' if you only need to display products and orders, or 'Read/Write' if you plan to create or update orders programmatically from Lovable. Click 'Generate API key' and WordPress will display your Consumer Key and Consumer Secret exactly once — copy both values immediately and save them somewhere secure like a password manager. The Consumer Secret is never shown again after you leave this page. The Consumer Key starts with ck_ and the Consumer Secret starts with cs_. Do not close this page until you have securely copied both values. Also note your store's base URL — this is typically https://yourstore.com.

Pro tip: If you accidentally close the page before copying the Consumer Secret, you will need to revoke and regenerate the key. There is no way to recover a lost WooCommerce Consumer Secret.

Expected result: You have a Consumer Key (ck_...) and Consumer Secret (cs_...) copied and ready to store in Lovable Cloud Secrets.

2

Add WooCommerce credentials to Cloud Secrets

In your Lovable project, click the '+' icon next to the Preview panel to open the Cloud tab. Look for the 'Secrets' section in the Cloud panel sidebar. Click 'Add Secret' and create three secrets that your Edge Function will need. First, add WOO_CONSUMER_KEY and paste your Consumer Key (the ck_... value). Second, add WOO_CONSUMER_SECRET and paste your Consumer Secret (the cs_... value). Third, add WOO_STORE_URL and paste your WordPress store's base URL — for example https://yourstore.com — with no trailing slash. Storing the URL as a secret is not strictly required for security (it is a public URL), but it makes your Edge Function environment-aware so you can test against a staging store without changing code. These secrets are encrypted at rest and accessible only from Edge Functions via Deno.env.get() — they are never sent to the browser or visible in your project's source code. Lovable's security layer blocks approximately 1,200 private API keys per day from being hardcoded into application code, and storing credentials here is how you stay protected.

Pro tip: Name your secrets exactly as shown: WOO_CONSUMER_KEY, WOO_CONSUMER_SECRET, WOO_STORE_URL. Your Edge Function code will reference these exact names with Deno.env.get().

Expected result: Three secrets (WOO_CONSUMER_KEY, WOO_CONSUMER_SECRET, WOO_STORE_URL) appear in your Cloud Secrets panel.

3

Create the WooCommerce proxy Edge Function

In Lovable's chat interface, ask Lovable to create a Supabase Edge Function that proxies requests to your WooCommerce REST API. The Edge Function needs to handle CORS, read your credentials from environment variables, encode them as Base64 for HTTP Basic Auth, forward the incoming request path and query parameters to WooCommerce, and return the JSON response to your frontend. The function should accept a 'path' query parameter that maps to a WooCommerce API endpoint (e.g., /products, /products/categories, /orders). Lovable will create the file at supabase/functions/woocommerce-proxy/index.ts and deploy it to your Cloud project automatically. The Edge Function runs on Deno, so you use Deno.env.get() to read secrets and the built-in fetch() for HTTP requests. WooCommerce REST API uses HTTP Basic Auth where you encode 'consumer_key:consumer_secret' as Base64 and pass it in the Authorization header.

Lovable Prompt

Create a Supabase Edge Function called woocommerce-proxy that proxies requests to my WooCommerce REST API. It should read WOO_CONSUMER_KEY, WOO_CONSUMER_SECRET, and WOO_STORE_URL from Deno.env.get(). Accept a 'path' query parameter for the WooCommerce endpoint (e.g., /products or /products/categories). Build the WooCommerce URL as WOO_STORE_URL + '/wp-json/wc/v3' + path + any additional query params. Authenticate using HTTP Basic Auth by encoding 'consumer_key:consumer_secret' as Base64. Return the WooCommerce JSON response to the caller with proper CORS headers.

Paste this in Lovable chat

supabase/functions/woocommerce-proxy/index.ts
1import { serve } from "https://deno.land/std@0.168.0/http/server.ts";
2
3const corsHeaders = {
4 "Access-Control-Allow-Origin": "*",
5 "Access-Control-Allow-Headers": "authorization, x-client-info, apikey, content-type",
6};
7
8serve(async (req) => {
9 if (req.method === "OPTIONS") {
10 return new Response("ok", { headers: corsHeaders });
11 }
12
13 try {
14 const consumerKey = Deno.env.get("WOO_CONSUMER_KEY");
15 const consumerSecret = Deno.env.get("WOO_CONSUMER_SECRET");
16 const storeUrl = Deno.env.get("WOO_STORE_URL");
17
18 if (!consumerKey || !consumerSecret || !storeUrl) {
19 return new Response(
20 JSON.stringify({ error: "WooCommerce credentials not configured" }),
21 { status: 500, headers: { ...corsHeaders, "Content-Type": "application/json" } }
22 );
23 }
24
25 const url = new URL(req.url);
26 const path = url.searchParams.get("path") || "/products";
27 url.searchParams.delete("path");
28
29 const wooUrl = new URL(`${storeUrl}/wp-json/wc/v3${path}`);
30 url.searchParams.forEach((value, key) => {
31 wooUrl.searchParams.set(key, value);
32 });
33
34 const credentials = btoa(`${consumerKey}:${consumerSecret}`);
35
36 const response = await fetch(wooUrl.toString(), {
37 method: req.method,
38 headers: {
39 "Authorization": `Basic ${credentials}`,
40 "Content-Type": "application/json",
41 },
42 body: req.method !== "GET" ? await req.text() : undefined,
43 });
44
45 const data = await response.json();
46
47 return new Response(JSON.stringify(data), {
48 status: response.status,
49 headers: { ...corsHeaders, "Content-Type": "application/json" },
50 });
51 } catch (error) {
52 return new Response(
53 JSON.stringify({ error: error.message }),
54 { status: 500, headers: { ...corsHeaders, "Content-Type": "application/json" } }
55 );
56 }
57});

Pro tip: The btoa() function is available natively in Deno for Base64 encoding. No extra import needed.

Expected result: The woocommerce-proxy Edge Function is deployed to your Cloud project. You can verify it appears under Cloud → Edge Functions.

4

Build the product catalog React component

With your Edge Function deployed, ask Lovable to build a React component that calls the Edge Function to fetch and display WooCommerce products. The component should use the Supabase client's built-in functions.invoke() method or a direct fetch() call to the Edge Function URL to retrieve product data. For a product catalog, you will typically want to call the /products endpoint with parameters for per_page (number of products to load), page (for pagination), category (optional filter), and status=publish to only show live products. Lovable can generate the full component including product cards with image, title, price, and add-to-cart button, a loading skeleton state while products are fetching, error handling if the Edge Function fails, and a category filter row using data from the /products/categories endpoint. You can use Tailwind CSS classes for styling and shadcn/ui Card components for the product cards — Lovable knows these libraries and will generate appropriate code automatically.

Lovable Prompt

Create a ProductCatalog React component that fetches products from my woocommerce-proxy Edge Function. Call the Edge Function with path=/products and parameters per_page=12&status=publish. Show a grid of product cards with product image, name, regular price, and a 'View Product' button. Add a loading state with skeleton cards and an error message if the fetch fails. Also fetch categories from path=/products/categories and display filter buttons above the grid.

Paste this in Lovable chat

src/components/ProductCatalog.tsx
1import { useEffect, useState } from "react";
2import { supabase } from "@/integrations/supabase/client";
3import { Card, CardContent } from "@/components/ui/card";
4import { Button } from "@/components/ui/button";
5import { Skeleton } from "@/components/ui/skeleton";
6
7interface WooProduct {
8 id: number;
9 name: string;
10 price: string;
11 regular_price: string;
12 images: { src: string; alt: string }[];
13 slug: string;
14 stock_status: string;
15}
16
17export function ProductCatalog() {
18 const [products, setProducts] = useState<WooProduct[]>([]);
19 const [loading, setLoading] = useState(true);
20 const [error, setError] = useState("");
21
22 useEffect(() => {
23 async function loadProducts() {
24 try {
25 const { data, error } = await supabase.functions.invoke("woocommerce-proxy", {
26 body: { path: "/products", per_page: 12, status: "publish" },
27 });
28 if (error) throw error;
29 setProducts(data);
30 } catch (err: any) {
31 setError(err.message || "Failed to load products");
32 } finally {
33 setLoading(false);
34 }
35 }
36 loadProducts();
37 }, []);
38
39 if (loading) return (
40 <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6 p-6">
41 {Array.from({ length: 6 }).map((_, i) => (
42 <Skeleton key={i} className="h-72 rounded-xl" />
43 ))}
44 </div>
45 );
46
47 if (error) return <p className="text-red-500 p-6">{error}</p>;
48
49 return (
50 <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6 p-6">
51 {products.map((product) => (
52 <Card key={product.id} className="overflow-hidden">
53 <img
54 src={product.images[0]?.src || "/placeholder.png"}
55 alt={product.images[0]?.alt || product.name}
56 className="w-full h-48 object-cover"
57 />
58 <CardContent className="p-4">
59 <h3 className="font-semibold text-lg">{product.name}</h3>
60 <p className="text-primary font-bold mt-1">${product.price}</p>
61 <Button className="mt-3 w-full" disabled={product.stock_status !== "instock"}>
62 {product.stock_status === "instock" ? "View Product" : "Out of Stock"}
63 </Button>
64 </CardContent>
65 </Card>
66 ))}
67 </div>
68 );
69}

Pro tip: Use supabase.functions.invoke() rather than raw fetch() for Edge Function calls — it automatically attaches the correct auth headers.

Expected result: Your React storefront displays a grid of WooCommerce products fetched live from your store.

5

Test the integration and handle pagination

Preview your Lovable project to confirm products are loading from WooCommerce. Open your browser's developer tools (F12) and check the Network tab to verify the Edge Function call is succeeding with a 200 response. If you see errors, go to Cloud → Logs in Lovable to read the Edge Function execution logs — this is the fastest way to debug credential issues or URL mismatches. WooCommerce REST API returns paginated results, with the total number of products in the X-WP-Total response header and total pages in X-WP-TotalPages. For stores with many products, implement pagination by passing the page parameter to the Edge Function. Ask Lovable to add 'Load More' or numbered pagination controls to your catalog component. Also test edge cases: products with no images (WooCommerce returns an empty images array), products that are out of stock (stock_status: 'outofstock'), and products with sale prices (regular_price vs price fields). For complex storefronts with custom WooCommerce plugins or unusual product types, RapidDev's team can help configure the Edge Function to handle non-standard API responses.

Lovable Prompt

Update my ProductCatalog component to support pagination. Add a 'Load More' button below the product grid that fetches the next page from the woocommerce-proxy Edge Function. Track the current page in state and increment it when Load More is clicked. Hide the button when there are no more products to load.

Paste this in Lovable chat

Pro tip: WooCommerce defaults to returning 10 products per page. Pass per_page=100 (maximum) if you want all products at once, but paginate for stores with large catalogs to keep load times fast.

Expected result: Products load correctly, pagination works, and out-of-stock or imageless products are handled gracefully.

Common use cases

Product catalog browser with category filtering

Pull your full WooCommerce product catalog into a React storefront with category filters, price sorting, and search. Product images, descriptions, pricing, and stock status all come from WooCommerce in real time via Edge Function.

Lovable Prompt

Create a product catalog page that fetches products from my WooCommerce store via an Edge Function. Show product cards with image, name, price, and stock status. Add category filter buttons at the top. The Edge Function should call /wp-json/wc/v3/products and pass the category parameter.

Copy this prompt to try it in Lovable

Single product page with variant selection

Display a detailed product page showing all WooCommerce product variations (size, color, etc.) with dynamic price updates. When a customer selects a variation, fetch the correct variation price and stock level from WooCommerce.

Lovable Prompt

Build a product detail page that loads a WooCommerce product by ID using an Edge Function calling /wp-json/wc/v3/products/{id}. Display product images, description, and a variation selector that shows the correct price and stock status when a customer picks size or color.

Copy this prompt to try it in Lovable

Order lookup tool for customers

Let customers enter their order number to look up order status, items, and tracking information. The Edge Function queries the WooCommerce Orders API and returns formatted order data without exposing admin credentials.

Lovable Prompt

Create an order lookup page where customers enter their order ID and email address. An Edge Function calls /wp-json/wc/v3/orders/{id} to verify their email matches and returns order status, line items, and shipping details. Show a clean order summary card.

Copy this prompt to try it in Lovable

Troubleshooting

Edge Function returns 401 Unauthorized from WooCommerce

Cause: The Consumer Key or Consumer Secret is incorrect, or the API key has been revoked in WordPress. This can also happen if the WooCommerce REST API permissions are set to 'Read' but you are making a write request.

Solution: Go to WooCommerce → Settings → Advanced → REST API in your WordPress admin and verify the key exists and is active. Check that you copied the Consumer Key (ck_...) and Consumer Secret (cs_...) into the correct Cloud Secrets fields — they are easy to swap. Regenerate the key if needed.

Edge Function returns 404 or HTML response instead of JSON

Cause: WordPress Pretty Permalinks are not enabled, causing /wp-json/wc/v3/ routes to return 404. Alternatively, the WOO_STORE_URL secret contains a trailing slash or is missing the HTTPS protocol prefix.

Solution: In WordPress admin, go to Settings → Permalinks and select 'Post name' or any option other than 'Plain'. Click Save Changes. Then verify WOO_STORE_URL in Cloud Secrets is formatted as https://yourstore.com with no trailing slash.

Products load in Lovable preview but Edge Function shows CORS errors in browser console

Cause: The Edge Function CORS headers are not being returned correctly, or you are calling WooCommerce directly from frontend code instead of through the Edge Function proxy.

Solution: Ensure your Edge Function returns corsHeaders on all responses including error responses and the OPTIONS preflight. Never call the WooCommerce API directly from React components — always route through the Edge Function. Check that the Edge Function handles the OPTIONS method and returns a 200 response with CORS headers for preflight requests.

typescript
1if (req.method === "OPTIONS") {
2 return new Response("ok", { headers: corsHeaders });
3}

WooCommerce returns empty product array even though products exist in the store

Cause: Products may have status 'draft' or 'private' rather than 'publish'. The API key may only have Read access to certain product types, or WooCommerce catalog visibility is set to 'Hidden' for those products.

Solution: Add status=publish to your API request parameters to explicitly filter for published products. In WooCommerce admin, check each product's Catalog visibility under Product data → Linked Products. Ensure the API key has sufficient read permissions for the product types you are querying.

Best practices

  • Always store WooCommerce Consumer Key and Consumer Secret in Cloud Secrets — never in component code, environment files checked into Git, or Lovable chat messages
  • Add request caching in your Edge Function or React components for product catalog data — WooCommerce product listings rarely change minute-to-minute and caching reduces load on your WordPress server
  • Handle the WooCommerce rate limit gracefully: WooCommerce REST API does not have a published rate limit, but shared hosting providers often throttle excessive requests — implement exponential backoff for retry logic
  • Use the per_page parameter strategically: fetch 12-24 products for catalog pages, and fetch individual products by ID for detail pages rather than fetching all products and filtering client-side
  • Test your WooCommerce URL and credentials before building the full storefront by calling a simple endpoint like /wp-json/wc/v3/products/categories from your Edge Function first
  • Use WooCommerce's built-in stock status field (instock, outofstock, onbackorder) to display accurate availability rather than relying on stock_quantity which can be null for non-tracked products
  • For checkout flows, redirect customers to your WooCommerce checkout page rather than rebuilding checkout in React — WooCommerce checkout handles payment gateways, tax, shipping, and order creation that are complex to replicate

Alternatives

Frequently asked questions

Does Lovable have a native WooCommerce connector like it does for Shopify?

No. As of March 2026, Lovable's 17 shared connectors include Shopify but not WooCommerce. WooCommerce integration requires creating a Supabase Edge Function proxy as described in this guide. Shopify's connector provides AI-assisted setup with no code required; WooCommerce requires the manual steps above.

Can I use this integration to accept payments through WooCommerce from my Lovable storefront?

The recommended approach is to redirect customers to your WooCommerce checkout page for payment. Rebuilding the entire WooCommerce checkout in React would require integrating all the payment gateways, tax calculation, and shipping logic that WooCommerce handles. Your Edge Function can create orders via the WooCommerce Orders API, then redirect the customer to the WooCommerce checkout URL to complete payment.

Will changes to my WooCommerce products automatically reflect in my Lovable storefront?

Yes. Because the Edge Function calls the WooCommerce REST API in real time on each page load, any changes you make in WooCommerce admin — pricing updates, new products, stock changes — are immediately reflected when a customer visits your Lovable storefront. There is no manual sync required.

Can I use this with WooCommerce running on localhost during development?

Not directly. Supabase Edge Functions run in Lovable Cloud and need to reach your WooCommerce server over a public internet connection. For local development, use a tool like ngrok to expose your local WordPress site to the internet temporarily, or use a staging site with a public URL.

What WooCommerce plan or hosting is required for this integration?

WooCommerce itself is free and open-source. You need any WordPress hosting that supports HTTPS (required for the REST API) and has Pretty Permalinks enabled. Shared hosting like SiteGround, Bluehost, or WP Engine all work. The WooCommerce REST API is included in every WooCommerce installation with no additional paid extensions needed.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.