> ## Documentation Index
> Fetch the complete documentation index at: https://docs.khaime.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Build your store with Lovable

> Get a shop website with your Khaime products, built for you by Lovable in a few taps. Khaime runs the products, cart, checkout and orders behind it.

# Build your store with Lovable

You already have a Khaime store with products. Lovable can build a shop website for it: you describe the look in plain words and Lovable designs every page. Khaime keeps doing the work behind it: your products and stock, the cart, checkout and payments, orders, receipts, cart recovery and Khai. You keep managing everything in your Khaime dashboard, as you do today.

You do not need to write code, copy keys or know how websites work.

> [card] [I want a new shop website](#build-a-new-shop-in-five-steps)
>
> Tap **Build my shop with Lovable** in Khaime. Lovable opens with everything filled in.

> [card] [I already have a website](#add-khaime-to-a-website-you-already-built)
>
> Built with Lovable, Bolt, v0 or Replit? Tap **Copy for Lovable** and paste it into its chat.

## Before you start

* **Add your products in Khaime first**, with photos and prices. Lovable builds the shop around what you sell, and anything you add later shows up on its own.
* **Add your logo** in Khaime (**Manage store**). Lovable uses it, and your brand colour, for the design.
* **A Lovable account.** You can sign up for free when Lovable opens. Lovable's own plans and credits are separate from Khaime.

## Build a new shop in five steps

**1. Tap Build my shop with Lovable**

In your Khaime dashboard, open **Your website** and tap **Build my shop with Lovable**. Lovable opens in a new tab. This also switches on selling from your website, so there is nothing else to set up.

**2. Sign in to Lovable and press send**

Sign in or sign up. The request is already written for you, with your store attached as a design reference. Lovable never starts until you press send, so you can add your own wishes first, for example *"warm and minimal, lots of white space, a dark green accent"*.

**3. Watch Lovable build your shop**

Lovable builds a home page with your products, a product page with photos and options, a cart, a checkout page and a thank-you page. It uses your real products, prices and photos from Khaime, in your store's colours.

**4. Test with a real order**

Your shop takes real payments from the start. In Lovable's preview, buy something cheap, check the order appears in **Orders** in Khaime, then refund it there.

**5. Publish**

Tap **Publish** in Lovable. Your shop works on Lovable's address straight away. To use your own domain, see [Your website address](#your-website-address).

After that, keep prompting Lovable to change anything you like: *"make the product photos bigger"*, *"add an About page"*, *"put the newest products first"*. The Khaime parts keep working.

### What Lovable gets when you tap the button

The button opens Lovable with two things, and nothing private:

1. **A request** to build your shop, with the Khaime setup in it: one script line, your store ID, your public store key, and the rules Lovable must follow (below).
2. **Your store page**, a public page Khaime makes from your store: your name, logo, brand colour, description, what you sell and your products with photos, prices and options. Lovable uses it to match your look. It is told not to copy products into the code, so your website always shows what is in Khaime right now.

## Add Khaime to a website you already built

If your website already exists, in Lovable or in Bolt, v0, Replit or another AI website builder:

1. In Khaime, open **Your website** and tap **Copy for Lovable**.
2. Paste it into your project chat and send it.

That is the same setup without the "build a whole shop" part. Lovable adds the Khaime script, creates `src/lib/khaime.ts` with your store ID, key and the rules, and shows your products on the home page.

## Everything Khaime does keeps working

Your Lovable shop is a full Khaime store, not just a catalogue:

| Feature | On your Lovable shop |
| - | - |
| **Store Pulse** | Visitors, live visitors, traffic sources, countries, product views, adds to cart, checkouts and sales. The Khaime script loads your store's tracking by itself, so there is nothing extra to add. |
| **Abandoned carts and checkouts** | When a shopper types their email at checkout and leaves, the cart is saved and they get your reminders (and Khai's messages, when Khai is on), the same as on your Khaime store. **Buy now** (digital products, gift cards, events) first asks for the shopper's name and email, so an unfinished Buy now is saved too. |
| **Popups, spin to win and chat** | Whatever you switch on in Khaime shows on your Lovable shop too. |
| **Orders, receipts, stock and payouts** | Exactly as in your Khaime store. |
| **Coupons, shipping and fees** | Worked out at checkout by Khaime. |

## The rules Lovable follows

Lovable writes them into `src/lib/khaime.ts` and reads that file before every later change to products, prices, the cart or checkout, so you never have to repeat them. In short:

* **Design is yours.** Every page and layout can look however you ask. Only the payment window belongs to Khaime.
* **Products come from Khaime**, through `khaime.getProducts()` and `khaime.getProduct(id)`. Never typed into the website.
* **Prices are shown exactly as Khaime sends them** (`formatted_price`). The website never adds, converts or discounts anything.
* **Options** (size, colour) come from `product.variants`. Each option carries its own full price, and sold-out options can't be picked.
* **Currency picker only when your store sells in several currencies** (see below).
* **Cart and checkout:** physical products go in `khaime.cart()`; the Checkout button goes to your own `/checkout` page, where `khaime.mountCartCheckout('#khaime-checkout')` shows the checkout as part of the page, not a popup ([how](https://docs.khaime.com/ai-builders/show-store-data.md#checkout-page)). Digital products, gift cards and events get a **Buy now** button instead.
* **No database, login, payment form or price sums** in the website. Khaime does all of that.
* **If anything from Khaime fails**, Lovable reads the `[Khaime]` message in the browser console and does what it says.

## Currency: shoppers pay in their own currency

> [!NOTE]
>
> **Shoppers can switch currency on your website, but only if your store sells in several currencies.**
>
> * **Your store sells in several currencies:** each shopper first sees prices in their own currency (a shopper in Nairobi sees KES), and a currency picker in the header lets them switch. The cart and checkout follow their choice.
> * **Your store sells in one currency:** every shopper sees that one currency and there is **no currency picker**. Checkout only takes that currency, so showing another would only lead to a failed payment.
>
> To sell in several currencies, request multi-currency access from **Products** in your Khaime dashboard. Once it is switched on, your website shows the picker by itself. You do not need to change anything in Lovable.

How the website does it: it calls `khaime.getCurrencies()` and shows the picker only when `canSwitch` is `true`. When a shopper picks one, it calls `khaime.setCurrency(code)`, which waits until the cart is repriced, and loads the products again.

## Options: sizes, colours and their prices

If a product has options, each one is in `product.variants` with its own **full price** already worked out, for example *Black: KES 21,623.68* when black costs more. The website shows that price when the option is picked and never adds prices together. Options you mark sold out in Khaime can't be picked, and stock you keep per option counts on its own: a hoodie with stock only on its colours still sells.

## Your website address

Your shop works on Lovable's preview and published addresses (`*.lovable.app`, `*.lovableproject.com`) as they are, and the same goes for Bolt (`*.bolt.host` and its editor preview) and v0 (`*.vusercontent.net`). Remixing or republishing there needs nothing from you.

When you connect your own domain, open **Your website** in Khaime. It shows *"Your shop was opened from myshop.com. Is this your website?"* Tap **Yes** and your shop works there. Once you have confirmed a website, any other address is refused until you say yes to it, so nobody can put your shop on their site.

## Before you go live

* [ ] Your products show with the right photos and prices.
* [ ] Picking an option shows that option's price.
* [ ] The currency picker shows only if your store sells in several currencies.
* [ ] Add to cart, the cart total and Checkout work on a phone.
* [ ] A test order appears in **Orders** in Khaime, and you refunded it.
* [ ] On your own domain, you tapped **Yes** on *"Is this your website?"* in Khaime.

## If something does not work

The Khaime script writes a plain message starting with `[Khaime]` in the browser console whenever something goes wrong, saying what happened and what to do. Lovable reads it and usually fixes it by itself. If it doesn't, paste the message into the Lovable chat. The common ones:

| The `[Khaime]` message says | What it means | Fix |
| - | - | - |
| This store key does not work any more | The key was replaced or typed wrong | Tap **Copy for Lovable** in Khaime again and paste it |
| This is not a Khaime store key | Something else was put in as the key | Same as above. A website key always starts with `pub_live_` |
| This is a private partner key (pk\_) | A private key was put in the website | Remove it at once, then paste the setup again. Contact support to replace that key |
| This website's address is not confirmed for this store yet | Your shop was opened on your own domain | Open **Your website** in Khaime and tap **Yes** |
| Selling from your own website is not switched on | Selling from your website is off | Tap **Build my shop with Lovable** or **Copy for Lovable** in Khaime once |
| That product or option is sold out | It was added after it sold out | Nothing to fix. Ask Lovable to show sold-out items as sold out |
| This store sells in one currency only | A currency picker was added anyway | Ask Lovable to remove the currency picker |
| Too many requests from this visitor | The page reloads products in a loop | Ask Lovable to load products once per page |
| Could not reach Khaime | No internet, or the script line is missing | Check the connection, then that the Khaime script line is in the page head |

> [!WARNING]
>
> Only ever give Lovable a key that starts with `pub_`. If Lovable ever asks you for a key that starts with `pk_`, say no: that key opens your orders, customers and payouts, and anything in your website code is public.

## Questions

**Do I need to update the website when I add or change products?** No. Products, prices, photos and stock load from Khaime each time a page opens.

**Can I change the design later?** Yes, as often as you like. Keep prompting Lovable. The rules in `src/lib/khaime.ts` keep the shop parts working.

**Who handles payments, shipping and refunds?** Khaime, exactly as in your Khaime store. Orders, payouts and refunds are all in your dashboard.

**Does this cost extra on Khaime?** No. Lovable charges for its own plans and credits.

**Can I ask Lovable about my sales too?** Yes. Connect Khaime to Lovable's chat and ask about sales, stock and Store Pulse. See [Ask about your store in Lovable](https://docs.khaime.com/ai-builders/lovable-chat.md).

**Can my website show my traffic or sales?** Not on a public page. A private page can, through a server function that holds your private key. See [Show your store's data](https://docs.khaime.com/ai-builders/show-store-data.md).

## Why it works this way

* **Your design stays yours.** Khaime sends Lovable plain product data, so Lovable can lay it out any way you ask.
* **Money stays safe.** Prices, shipping, coupons and fees are worked out by Khaime when the shopper pays, so nothing typed into a website can change what is charged.
* **Your key is safe to show.** A storefront key can only show your products and start a checkout. It cannot see orders or customers or touch payouts.
* **Nothing private in the link.** The button only carries your public store key and your public store page. Lovable never sees your password or private keys.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.