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

How to Integrate Lovable with Spocket

Integrate Spocket with your Lovable app using a Supabase Edge Function that authenticates with the Spocket API and proxies product, order, and supplier data to your frontend. Store your Spocket API credentials in Cloud → Secrets, then build dropshipping dashboards that display US and EU supplier products with 2-5 day shipping times. Spocket's API enables automated order fulfillment so customer purchases are sent directly to suppliers for fast domestic shipping.

What you'll learn

  • How to obtain Spocket API credentials and configure access for your Lovable project
  • How to store Spocket credentials securely in Lovable's Cloud → Secrets
  • How to create a Deno Edge Function that proxies Spocket product and order API calls
  • How to build a product discovery interface showing US and EU supplier items with shipping details
  • How to automate order submission to Spocket suppliers when a customer places an order
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Intermediate13 min read45 minutesE-commerceMarch 2026RapidDev Engineering Team
TL;DR

Integrate Spocket with your Lovable app using a Supabase Edge Function that authenticates with the Spocket API and proxies product, order, and supplier data to your frontend. Store your Spocket API credentials in Cloud → Secrets, then build dropshipping dashboards that display US and EU supplier products with 2-5 day shipping times. Spocket's API enables automated order fulfillment so customer purchases are sent directly to suppliers for fast domestic shipping.

Build a US and EU dropshipping store with Spocket in Lovable

Spocket solves one of the biggest frustrations with traditional dropshipping: slow shipping times from overseas suppliers. By focusing exclusively on US and EU suppliers, Spocket enables 2-5 day delivery windows that match customer expectations set by Amazon Prime. For founders building Lovable-based e-commerce apps, Spocket's API provides programmatic access to a curated product catalog, supplier inventory levels, and automated order routing — the three core pieces of a dropshipping operation.

The Spocket API lets you browse and import products from vetted suppliers, sync inventory levels so you never oversell, and submit customer orders directly to the responsible supplier for fulfillment. When a customer buys from your Lovable-built storefront, your app calls a Spocket API endpoint to create the order, and Spocket routes it to the appropriate supplier who ships directly to your customer. This flow is often called automated fulfillment, and it means you never touch the physical product.

This guide covers the complete integration: API access setup, Edge Function proxy, product browsing interface, and automated order submission. Because Spocket's API requires authentication headers on every request, all API calls run through a server-side Edge Function in Lovable — your API key never reaches the browser, and your storefront stays secure even if your frontend code is inspected.

Integration method

Edge Function Integration

Spocket's API uses token-based authentication that must be kept server-side. A Supabase Edge Function in your Lovable project proxies all Spocket API calls — browsing supplier products, importing listings, and submitting orders — while your React frontend displays the data and handles the user interface. Spocket credentials live in Lovable's encrypted Cloud → Secrets panel, never in browser code.

Prerequisites

  • A Lovable account with an active project
  • A Spocket account — free trial available, paid plan required for API access (Starter plan or above)
  • Spocket API credentials from your Spocket dashboard under Settings → API
  • A product strategy: know which categories and supplier locations you want to sell
  • A Supabase database to store imported products and order records (Lovable Cloud includes this automatically)

Step-by-step guide

1

Access the Spocket API and obtain your credentials

Log in to your Spocket account at app.spocket.co. Spocket API access requires a paid subscription — the Starter plan and above include API access. Navigate to your account settings by clicking your profile icon in the top right, then select 'Account Settings.' Look for the 'Integrations' or 'API' section, where Spocket provides your API key or bearer token. Spocket uses OAuth2 for its partner API — you may need to apply for API access through Spocket's developer program at developers.spocket.co if your account does not already show API credentials. The developer program provides a client ID and client secret for generating access tokens. For accounts that have direct API key access, you will see a single API token that you can use directly as a Bearer token in requests. Copy your API credentials carefully — you will use them in the next step. Note that Spocket's API base URL is https://app.spocket.co/api/v1 and all endpoints require your Bearer token in the Authorization header. Spocket periodically updates its API — check the documentation at developers.spocket.co for the most current endpoint structure and any rate limits that apply to your plan.

Pro tip: If you do not see API credentials in your Spocket account settings, contact Spocket support to enable API access for your account. Some API features require a Pro or Empire plan.

Expected result: You have a Spocket API token or client credentials that will authenticate requests to the Spocket API.

2

Store Spocket credentials in Cloud → Secrets

In Lovable, open the Cloud tab by clicking the '+' icon next to the Preview panel and navigate to the Secrets section. Click 'Add Secret' and create your Spocket credential secret. If Spocket provided a direct API token, add SPOCKET_API_TOKEN with the token value. If Spocket provided OAuth2 client credentials, add SPOCKET_CLIENT_ID and SPOCKET_CLIENT_SECRET separately. Using a separate secret for each credential value makes it easier to rotate them individually if needed. Your Edge Function will read these values using Deno.env.get() at runtime — they are never embedded in your app's JavaScript bundle or visible in browser developer tools. Lovable's security infrastructure encrypts these secrets at rest and blocks approximately 1,200 hardcoded API keys per day from appearing in generated code. For a dropshipping business, protecting your Spocket credentials is important because access to your account could allow someone to place orders billed to your account.

Pro tip: If your Spocket token expires periodically, store both the token and its expiry timestamp. Add token refresh logic to your Edge Function that obtains a new token when the current one is within 5 minutes of expiry.

Expected result: SPOCKET_API_TOKEN (and optionally SPOCKET_CLIENT_ID and SPOCKET_CLIENT_SECRET) appear in Cloud → Secrets.

3

Deploy the Spocket proxy Edge Function

Use Lovable's chat to generate the Spocket proxy Edge Function. This function accepts POST requests from your frontend containing the Spocket API endpoint path, the HTTP method, and an optional request body. It reads your Spocket credentials from Deno environment variables, constructs the full Spocket API URL, and forwards the request with the Authorization header. The function returns the Spocket API response to your frontend as JSON. This proxy pattern solves two problems simultaneously: it keeps your API credentials server-side where they cannot be extracted from browser memory, and it eliminates CORS errors since Spocket's API does not include CORS headers for browser requests. Your frontend only ever makes requests to your own Supabase Edge Function URL — Spocket's domain is never directly accessed from the browser.

Lovable Prompt

Create a Supabase Edge Function at supabase/functions/spocket-proxy/index.ts that proxies requests to the Spocket API. The function should: 1) Read SPOCKET_API_TOKEN from Deno environment. 2) Accept POST requests with JSON body containing 'endpoint' (path like '/api/v1/products'), 'method' (defaults to GET), and optional 'body'. 3) Make the request to 'https://app.spocket.co' + endpoint with Authorization: Bearer token header. 4) Return the Spocket response with CORS headers. Handle errors gracefully and return descriptive error messages.

Paste this in Lovable chat

supabase/functions/spocket-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 apiToken = Deno.env.get("SPOCKET_API_TOKEN");
15 if (!apiToken) throw new Error("SPOCKET_API_TOKEN not configured in Secrets");
16
17 const { endpoint, method = "GET", body } = await req.json();
18 if (!endpoint) throw new Error("'endpoint' is required");
19
20 const url = `https://app.spocket.co${endpoint}`;
21
22 const fetchOptions: RequestInit = {
23 method,
24 headers: {
25 Authorization: `Bearer ${apiToken}`,
26 "Content-Type": "application/json",
27 Accept: "application/json",
28 },
29 };
30
31 if (body && method !== "GET") {
32 fetchOptions.body = JSON.stringify(body);
33 }
34
35 const response = await fetch(url, fetchOptions);
36 let data;
37 const contentType = response.headers.get("content-type") || "";
38 if (contentType.includes("application/json")) {
39 data = await response.json();
40 } else {
41 data = { message: await response.text() };
42 }
43
44 return new Response(JSON.stringify(data), {
45 headers: { ...corsHeaders, "Content-Type": "application/json" },
46 status: response.ok ? 200 : response.status,
47 });
48 } catch (error) {
49 return new Response(
50 JSON.stringify({ error: error.message }),
51 { headers: { ...corsHeaders, "Content-Type": "application/json" }, status: 500 }
52 );
53 }
54});

Pro tip: Spocket's API responses include pagination metadata. When fetching product lists, check the response for total_count and use the page and limit query parameters to implement proper pagination in your product browser.

Expected result: The spocket-proxy Edge Function shows as deployed in Cloud tab. Your React frontend can now call /functions/v1/spocket-proxy to reach any Spocket API endpoint.

4

Build the product catalog browser

With the proxy deployed, prompt Lovable to create the product discovery interface that lets you browse Spocket's supplier catalog and import products to your store. Spocket's products endpoint returns key data for each product including the supplier location (US, Canada, EU countries), the supplier's price (your cost), the suggested retail price, processing time in days, and inventory levels. Filtering products by ship_from_us=true or ship_from_eu=true lets you specifically target fast-shipping suppliers. The import flow involves saving the Spocket product ID and your desired retail price to a Supabase table — this becomes your product catalog for the storefront. When displaying products on your customer-facing storefront, you fetch from Supabase (your imported products table) rather than from Spocket directly, which is faster and avoids unnecessary Spocket API calls on every page load.

Lovable Prompt

Build a ProductBrowser component for my dropshipping admin. Call /functions/v1/spocket-proxy with endpoint '/api/v1/products?ship_from_us=true&limit=24&page=1' to fetch US-based supplier products. Display each product in a card with: supplier image, product name, supplier price (cost), suggested retail price, shipping time in days, and supplier country flag. Add a category filter dropdown and a 'US Only / EU Only / All' toggle. Each card has an 'Import' button. When Import is clicked, show a small form to set my retail price and markup percentage, then save to Supabase 'imported_products' table with fields: spocket_product_id, title, supplier_price, retail_price, image_url, shipping_days, supplier_country, is_active.

Paste this in Lovable chat

Pro tip: Calculate and display profit margin on each product card: ((retail_price - supplier_price) / retail_price) * 100. This helps you quickly identify which products offer the best margins without manual calculation.

Expected result: The product browser displays Spocket supplier products with filtering options. Importing a product saves it to your Supabase table with your chosen retail price.

5

Automate order fulfillment to Spocket suppliers

The final piece of the dropshipping workflow is automated order submission. When a customer pays for an order on your storefront, your app needs to submit that order to Spocket so the supplier can fulfill it. This is typically triggered by a Stripe webhook (when payment is captured) or a Supabase database trigger (when an order's payment_status changes to 'paid'). The order submission to Spocket requires the Spocket product ID, the customer's shipping address in the format Spocket expects, and the quantity. Spocket responds with a Spocket order ID and an estimated ship date. Save the Spocket order ID in your orders table so you can check fulfillment status later. For customer order tracking, poll the Spocket order status endpoint periodically and display the status in your customer-facing order detail page. RapidDev's team can help configure the complete webhook-to-fulfillment pipeline for more complex multi-supplier order routing scenarios.

Lovable Prompt

Create an order fulfillment system. Add a Supabase database function that triggers when an order's payment_status changes to 'paid'. For each order item, look up the spocket_product_id from the imported_products table. Then call /functions/v1/spocket-proxy to POST to '/api/v1/orders' with body: { product_id: spocketProductId, quantity: item.quantity, shipping_address: { first_name, last_name, address1, city, state, zip, country_code } }. Save the response's order_id as spocket_order_id in the order record. On the order detail page, display fulfillment status by calling GET /api/v1/orders/{spocketOrderId} through the proxy.

Paste this in Lovable chat

Pro tip: Add error handling for cases where a Spocket order submission fails — for example, if a product goes out of stock between the customer browsing and placing the order. In that case, trigger a refund flow and notify the customer rather than leaving the order in a failed state silently.

Expected result: When an order is marked as paid in your Supabase database, it is automatically submitted to Spocket for fulfillment, and the Spocket order ID is saved back to the order record.

Common use cases

Product discovery and import dashboard

Build an admin interface where you browse Spocket's supplier catalog filtered by category, shipping location, price range, and processing time. Import products you want to sell, set your markup percentage, and sync them to your storefront — all from a single Lovable-built dashboard.

Lovable Prompt

Build a product discovery page that calls /functions/v1/spocket-proxy with endpoint '/api/v1/products?ship_from_us=true&limit=24&page=1'. Display products in a grid with product image, name, supplier price, shipping time, and supplier country. Add filters for category and maximum price. Add an 'Import Product' button on each card that saves the product to a Supabase 'imported_products' table with a markup percentage field. Show an indicator if a product is already imported.

Copy this prompt to try it in Lovable

Automated order fulfillment pipeline

When a customer completes checkout on your Lovable storefront, automatically submit the order to Spocket for fulfillment. Spocket routes the order to the supplier, who ships directly to the customer. Your app tracks fulfillment status by polling the Spocket order endpoint.

Lovable Prompt

Create an order fulfillment system that triggers when a new order is added to my Supabase orders table. For each order item, check the imported_products table to find the Spocket product ID, then call /functions/v1/spocket-proxy to POST to '/api/v1/orders' with the customer's shipping address and the Spocket product ID and quantity. Save the returned Spocket order ID back to the order record. On the order detail page, show the Spocket fulfillment status by calling GET /api/v1/orders/{spocketOrderId}.

Copy this prompt to try it in Lovable

Inventory sync and stock management

Keep your storefront's displayed inventory levels in sync with Spocket supplier availability. Run a periodic check against Spocket's inventory endpoint and update your Supabase product table to mark items as out of stock when supplier inventory drops to zero.

Lovable Prompt

Build an inventory sync function that calls /functions/v1/spocket-proxy to fetch current inventory for all my imported Spocket products by calling GET /api/v1/products/{productId} for each item in my imported_products table. Compare the returned stock quantity to what is stored in Supabase. Update any products where the inventory has changed. Show a 'Sync Inventory' button in my admin dashboard that triggers this process and displays a summary of how many products were updated.

Copy this prompt to try it in Lovable

Troubleshooting

Edge Function returns 401 Unauthorized for all Spocket API calls

Cause: The SPOCKET_API_TOKEN secret is missing, expired, or incorrect. Spocket API tokens can expire depending on your account type.

Solution: Open Cloud → Secrets and verify SPOCKET_API_TOKEN is present and contains the full token value with no extra whitespace. Log in to your Spocket account and navigate to Settings → API to verify the token has not been revoked or rotated. If your Spocket plan uses OAuth2 credentials, verify that your token generation flow is working correctly and that the obtained token is being stored and retrieved properly.

Order submission to Spocket fails with 'Product not available' or 'Out of stock'

Cause: The Spocket supplier's inventory for the product dropped to zero between when you imported the product and when the customer placed the order. Dropshipping inventory is real-time and suppliers can sell out.

Solution: Before submitting an order to Spocket, call GET /api/v1/products/{spocketProductId} through your proxy to check current inventory. If inventory is 0, trigger a customer notification and refund workflow rather than attempting the Spocket order. Implement a daily inventory sync using a Supabase scheduled function to keep your local product availability data current and hide out-of-stock items from your storefront automatically.

Product images load in the admin dashboard but not on the customer-facing storefront

Cause: Spocket product image URLs are hosted on Spocket's CDN with access controls. Direct image URLs may have referrer restrictions or expire.

Solution: When importing products to your Supabase imported_products table, store the image URL and periodically re-fetch if images stop loading. Alternatively, download and re-host product images in Lovable Cloud Storage (Supabase Storage) when importing, so you control the image hosting. This also improves storefront performance since images load from your CDN rather than Spocket's.

Spocket API returns 429 Too Many Requests during product sync

Cause: Your sync operation is making more requests than Spocket's rate limit allows for your plan tier.

Solution: Add a delay between batches of product sync requests. Implement a queue-based approach where you process products in batches of 10, with a 1-second pause between batches, rather than making all requests simultaneously. For large catalogs, schedule the sync to run during off-peak hours using a Supabase scheduled function (cron) rather than triggering it manually.

typescript
1// Batch processing with delay
2async function syncProducts(productIds: string[]) {
3 const BATCH_SIZE = 10;
4 const DELAY_MS = 1000;
5
6 for (let i = 0; i < productIds.length; i += BATCH_SIZE) {
7 const batch = productIds.slice(i, i + BATCH_SIZE);
8 await Promise.all(batch.map(id => fetchProductInventory(id)));
9 if (i + BATCH_SIZE < productIds.length) {
10 await new Promise(resolve => setTimeout(resolve, DELAY_MS));
11 }
12 }
13}

Best practices

  • Store imported products in your own Supabase database rather than fetching from Spocket on every storefront page load — this dramatically reduces API calls and improves storefront performance.
  • Run a daily inventory sync to update stock levels for all imported products, and automatically hide or mark as out-of-stock any products with zero inventory.
  • Check current product inventory immediately before submitting an order to Spocket — dropshipping inventory can change rapidly and a failed order after payment is a poor customer experience.
  • Display supplier shipping times (2-5 days for US/EU) prominently on product pages, since this is Spocket's key differentiator over AliExpress-based dropshipping and a strong selling point for customers.
  • Calculate and track your margins per product (retail price minus Spocket supplier cost) in your imported_products table to identify your most profitable items for marketing focus.
  • Implement automatic order status email notifications to customers using Lovable's built-in email capability or a Resend Edge Function, triggered when the Spocket fulfillment status changes.
  • Test the complete order flow with a test purchase to yourself before launching — verify that the Spocket order is created, the supplier receives it, and the tracking number eventually appears in the Spocket order record.
  • Keep a fallback contact method (supplier contact from Spocket dashboard) for orders that get stuck in processing, since automated fulfillment occasionally needs manual intervention for address issues.

Alternatives

Frequently asked questions

What Spocket plan do I need to use the API?

Spocket API access requires a paid subscription — the free trial and the basic Starter plan have limited API access. The Pro plan and above provide full API capabilities including order automation. Check your Spocket account settings under Integrations to see whether API credentials are available on your current plan. Contact Spocket's support team if you need to discuss API access for higher-volume integrations.

How does Spocket handle returns and customer service for dropshipped orders?

When a customer wants to return a Spocket-fulfilled order, you handle the customer-facing side (refund, replacement), and then coordinate with the specific Spocket supplier for product return logistics. Spocket's dashboard lets you open supplier support tickets for order issues. In your Lovable app, plan a return management workflow that notifies you when a customer initiates a return so you can process it promptly — returns are a significant operational consideration for dropshipping businesses.

Can I use Spocket with a custom Lovable storefront instead of Shopify or WooCommerce?

Yes — that is exactly what this integration guide enables. Most Spocket documentation targets Shopify and WooCommerce integrations, but the underlying Spocket API works with any storefront. Your Lovable app handles the customer experience (browsing, cart, checkout) while the Spocket API Edge Function handles product sourcing and order fulfillment. You do need to handle payment processing separately, typically through Stripe's native Lovable connector.

How do I handle the case where a supplier changes their price after I have set my retail price?

Spocket supplier prices can change. Include the supplier's current price in your daily inventory sync — when the supplier price increases beyond your retail price (which would make you lose money on sales), automatically flag those products in your admin dashboard so you can update your retail price. Store the last known supplier price in your Supabase imported_products table and alert yourself when it changes by more than 10%.

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.