Svelte Commerce × Broadleaf

Svelte Commerce on Broadleaf

The Broadleaf connector targets Broadleaf Microservices — 41 OpenAPI 3.0.3 documents — not the legacy 5.x/6.x monolith, which publishes no versioned REST contract. Cart, checkout and sign-in are wired, and CONNECTORS.md records no gaps.

What works on Broadleaf today

Cart, checkout and sign-in are wired, with no gaps recorded. One question is open with Broadleaf: its published CartPricing schema has no cart total, though its demo gateway returns one, so a deployment that follows the spec to the letter would show a total of zero.

Cart

Wired: issues a real request to Broadleaf.

Checkout

Wired: issues a real request to Broadleaf.

Sign-in (auth)

Wired: issues a real request to Broadleaf.

Known gaps: none recorded.

28 of 43 services wired, read from CONNECTORS.md on , where the package version is recorded too; npm may carry a newer patch. Coverage is traced by a script in the Svelte Commerce repository: a service counts as wired only if it transitively issues an HTTP request, or delegates to one that does. It is not hand-asserted. Some services are Litekart-native concepts with no equivalent elsewhere (reels, deals, chat, gallery, popularity, demo-request, feedback, plugins, banner). They stay documented placeholders on every connector and are excluded from known gaps.

Quick start

From nothing to a Svelte Commerce storefront reading Broadleaf. You need Node.js and a Broadleaf to point it at; the storefront holds no data of its own.

Clone it, choose the connector, point it at Broadleaf

# 1 — get the storefront
git clone https://github.com/itswadesh/svelte-commerce
cd svelte-commerce

# 2 — one connector at a time: remove the two the storefront ships with, add this one
npm uninstall @misiki/litekart-connector @misiki/vendure-connector
npm i @misiki/broadleaf-connector

# 3 — point it at your Broadleaf gateway
echo PUBLIC_BROADLEAF_API_URL=https://your-store.example.com >> .env

# 4 — run it
npm run dev

The guide removes only @misiki/litekart-connector. A fresh clone’s package.json also lists @misiki/vendure-connector, and with two connectors installed and neither of them Litekart’s, the build stops and asks for PUBLIC_CONNECTOR — so this removes both.

Environment variables

What Svelte Commerce reads to reach Broadleaf
VariableRequiredWhat it does
PUBLIC_BROADLEAF_API_URLYesBase URL of your Broadleaf Microservices gateway. Boot fails, naming this variable, if it is missing.
PUBLIC_BROADLEAF_API_KEYNoOAuth client ID. With the secret, the connector requests a client-credentials token, which menu, customer and ratings calls need; catalogue browsing does not.
PUBLIC_BROADLEAF_API_SECRETNoOAuth client secret, sent with the ID as HTTP Basic to /oauth/token. See the limitations before setting it.
PUBLIC_BROADLEAF_ACCESS_TOKENNoA bearer token to use instead; when one is set, the connector skips the client-credentials request.
PUBLIC_BROADLEAF_STORE_IDNoSent as Broadleaf’s applicationId.
PUBLIC_BROADLEAF_CHANNEL_IDNoSent as Broadleaf’s tenantId.
PUBLIC_CONNECTORNoOnly when more than one connector is installed: @misiki/broadleaf-connector names the one this build runs on.

init.ts hands the connector every PUBLIC_BROADLEAF_* variable that is set, camel-cased: PUBLIC_BROADLEAF_STORE_ID arrives as storeId. The guide also lists PUBLIC_BROADLEAF_ACCESS_KEY; the connector’s source does not read it.

Every variable here begins PUBLIC_, and SvelteKit sends PUBLIC_ variables to the browser: treat each value you set as published.

What to set up on Broadleaf

How the integration works

The connector speaks Broadleaf Microservices’ REST APIs, as described by 41 OpenAPI 3.0.3 documents, and not the 5.x/6.x monolith. It takes a client-credentials token when it has an OAuth client ID and secret, and sends tenantId and applicationId from the channel and store variables.

Installing the package is the whole switch. vite.config.ts resolves whichever @misiki/*-connector is installed, and src/lib/core/connectors/init.ts hands it every PUBLIC_BROADLEAF_* variable that is set, camel-cased, at boot — in the server hook for server rendering and in the client hook for the browser, which must reach the same URL in production.

There is no Litekart API behind the storefront here, so store identity — name, logo, currency, menus, plugin toggles, theme colours — comes from src/lib/core/connectors/default-store.json merged under the default export of kitcommerce.config.ts. Until you override it, the store is called “Test”. Any Litekart REST path the connector still inherits is answered from that local data, or resolved empty, rather than requested.

Limitations

Troubleshooting

Errors you may meet running Svelte Commerce on Broadleaf, and what fixes them
When you seeWhat to do
Boot fails with “the broadleaf connector is active but PUBLIC_BROADLEAF_API_URL is not set”Add PUBLIC_BROADLEAF_API_URL to .env. A production Node build and Docker read PUBLIC_* from the process environment rather than .env, so set it on your deploy platform too.
The build stops with “Several commerce connectors are installed … Set PUBLIC_CONNECTOR to pick one”More than one @misiki/*-connector is in package.json and none is Litekart’s. Uninstall the ones you do not run — a fresh clone also lists @misiki/vendure-connector — or set PUBLIC_CONNECTOR='@misiki/broadleaf-connector'.
Boot fails with “PUBLIC_…_API_URL is set, but it configures a different backend than the one this build runs on”Another backend’s variable is still set, usually left over from the one you switched from. Remove it, or install that backend’s connector. PUBLIC_LITEKART_API_URL is exempt: it only points the dev proxy.
The store is called “Test”, or shows the wrong name and logoStore identity is static on this backend. Set name, logo, currencyCode and the rest in the default export of kitcommerce.config.ts; src/lib/core/connectors/default-store.json lists every field.
[broadleaf] no native implementation for get /api/... in the consoleThe connector’s REST guard caught a path inherited from Litekart and answered it empty instead of requesting it. Each path is reported once. Harmless if Broadleaf has no such feature; if it has one, the fix belongs in the connector’s matching service.
http proxy error: api/... ECONNREFUSED in devA Litekart REST path was requested from outside the connector, so its guard never saw it. Vite proxies /api to PUBLIC_LITEKART_API_URL, or to localhost:7000.
The build fails on @misiki/litekart-connector@misiki/kitcommerce-core declares it as a peer, and vite.config.ts redirects that specifier to whichever connector is installed. Make sure exactly one @misiki/*-connector is listed in package.json.

Before you rely on it

The one caveat that matters

Read this before choosing

Every connector was written by reading its platform’s authoritative source — an OpenAPI spec, a RAML file, a router registration or the controller source — rather than by running against a store. No connector has been exercised against a live production instance of its platform.

An open question for Broadleaf’s maintainers: CartPricing in the published schema has no total, adjustmentsTotal or feesTotal, but the demo gateway returns them. Which is authoritative?

Offer a sandbox or a correction

FAQ

Questions about Svelte Commerce on Broadleaf

Can I run a Broadleaf store on Svelte Commerce today?

Cart, checkout and sign-in are wired against Broadleaf Microservices and no gaps are recorded, so it is one of the more complete connectors. Check your cart totals first: Broadleaf’s published schema omits them, and a gateway that follows it strictly would show zero.

How do I switch Svelte Commerce to Broadleaf?

Remove the connectors the storefront ships with, install @misiki/broadleaf-connector, set PUBLIC_BROADLEAF_API_URL in .env and start the dev server. vite.config.ts resolves whichever connector is installed, so no file in the storefront changes.

Does the connector work with Broadleaf 5.x or 6.x?

No. It targets Broadleaf Microservices, described by 41 OpenAPI 3.0.3 documents. The 5.x/6.x monolith publishes no versioned REST contract, so there was nothing to wire against.

Has the Broadleaf connector been run against a real Broadleaf store?

Not against a live production instance — no Svelte Commerce connector has been. It was written by reading Broadleaf’s authoritative API source, and the Svelte Commerce maintainers ask Broadleaf’s own maintainers for a sandbox to run it against.

Sources

This page summarises BROADLEAF.md in the Svelte Commerce repository and the Broadleaf connector’s source, read on , and the coverage in CONNECTORS.md, read on . Where they disagree with this page, they are right and this page is out of date. Broadleaf is a trademark of its owner, named here only to describe compatibility; no endorsement or affiliation is implied — see trademarks.

Read the whole guide

The storefront is the same on every backend; the connector is what changes. BROADLEAF.md has the Broadleaf setup in full, beside the connector’s source.

Chat on WhatsApp