Svelte Commerce × Magento
Svelte Commerce on Magento
Customer sign-in through Magento’s /V1/integration/customer/token works well, and cart, checkout and sign-in are all wired. Reviews and wishlist are gaps because Magento ships no REST surface for either.
- 26/43 services wired
- @misiki/magento-connector 0.4.0
- Cart wired
- Checkout wired
- Sign-in (auth) wired
What works on Magento today
Cart, checkout and sign-in are wired; reviews and wishlist are not, because Magento has no REST API for them. The catch is the catalogue: it needs an admin or integration token, and the connector takes that token from a PUBLIC_ variable, which the browser receives.
Cart
Wired: issues a real request to Magento.
Checkout
Wired: issues a real request to Magento.
Sign-in (auth)
Wired: issues a real request to Magento.
Known gaps: review, wishlist — each is explained under Limitations below.
26 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 Magento. You need Node.js and a Magento to point it at; the storefront holds no data of its own.
Clone it, choose the connector, point it at Magento
# 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/magento-connector
# 3 — point it at your Magento store
echo PUBLIC_MAGENTO_API_URL=https://your-store.example.com >> .env
echo PUBLIC_MAGENTO_ACCESS_TOKEN=... >> .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
| Variable | Required | What it does |
|---|---|---|
PUBLIC_MAGENTO_API_URL | Yes | Your Magento base URL; the connector builds {url}/rest[/{store_code}]/V1. Boot fails, naming this variable, if it is missing. |
PUBLIC_MAGENTO_ACCESS_TOKEN | No | An admin or integration access token. The connector sends it on catalogue, CMS, order, coupon and store-configuration calls, which reject a customer token. See the limitations. |
PUBLIC_MAGENTO_STORE_ID | No | A store view code, such as default, used to scope requests. Used only when it looks like a code rather than a numeric ID. |
PUBLIC_CONNECTOR | No | Only when more than one connector is installed: @misiki/magento-connector names the one this build runs on. |
init.ts hands the connector every PUBLIC_MAGENTO_* variable that is set, camel-cased. The guide also lists PUBLIC_MAGENTO_API_KEY, PUBLIC_MAGENTO_API_SECRET, PUBLIC_MAGENTO_ACCESS_KEY and PUBLIC_MAGENTO_CHANNEL_ID; the connector’s source does not read them.
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 Magento
- Since Magento 2.4.4, an integration token works as a standalone bearer token only once you enable Stores › Configuration › Services › OAuth › Consumer Settings › “Allow OAuth Access Tokens to be used as standalone Bearer tokens” (
bin/magento config:set oauth/consumer/enable_integration_as_bearer 1). Without it, every admin route returns 401. - Let the storefront’s origin make cross-origin requests to Magento (CORS): in production the browser calls
PUBLIC_MAGENTO_API_URLdirectly, not only the server.
How the integration works
The connector speaks Magento’s REST API under /rest/V1, scoped to a store view when one is set. It picks a token per call: the shopper’s customer token for their own cart and account, the admin or integration token for catalogue, CMS, orders and coupons — which have no shopper-level access — and no token at all for guest carts and search.
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_MAGENTO_* 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
- Reviews: not wired —
Magento_Reviewships nowebapi.xml, so there is no REST surface to call. - Wishlist: not wired —
Magento_Wishlistships nowebapi.xmleither. - Pages that depend on a service that is not wired render their empty state rather than failing.
- The admin or integration token the connector needs for the catalogue comes from
PUBLIC_MAGENTO_ACCESS_TOKEN. SvelteKit sendsPUBLIC_variables to the browser, so every visitor to the store can read that token and use whatever access the integration has. - Homepage sections other than the live product list come from the active theme’s static content — the standing rule for themes.
- The Conversational Shopping assistant is Litekart-only; its widget stays hidden when another connector is active.
Troubleshooting
| When you see | What to do |
|---|---|
| Every catalogue call returns 401 | On Magento 2.4.4 and later, enable “Allow OAuth Access Tokens to be used as standalone Bearer tokens” (bin/magento config:set oauth/consumer/enable_integration_as_bearer 1). Until you do, an integration token is refused on every admin route. |
| Boot fails with “the magento connector is active but PUBLIC_MAGENTO_API_URL is not set” | Add PUBLIC_MAGENTO_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/magento-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 logo | Store 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. |
[magento] no native implementation for get /api/... in the console | The 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 Magento has no such feature; if it has one, the fix belongs in the connector’s matching service. |
http proxy error: api/... ECONNREFUSED in dev | A 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 Magento’s maintainers: Is exposing a REST surface for reviews and wishlist planned, or is a custom module the expected answer?
Offer a sandbox or a correctionFAQ
Questions about Svelte Commerce on Magento
Can I run a Magento store on Svelte Commerce today?
Cart, checkout and sign-in are wired; reviews and wishlist are not. The obstacle is the catalogue token: the connector needs an admin or integration token and reads it from a PUBLIC_ variable, which every visitor’s browser receives. Weigh that before deploying.
How do I switch Svelte Commerce to Magento?
Remove the connectors the storefront ships with, install @misiki/magento-connector, set PUBLIC_MAGENTO_API_URL in .env and start the dev server. vite.config.ts resolves whichever connector is installed, so no file in the storefront changes.
Why are reviews and wishlists missing on Magento?
Because Magento has no REST API for them: the Magento_Review and Magento_Wishlist modules ship no webapi.xml. The Svelte Commerce maintainers have asked Magento’s maintainers whether exposing them is planned, or whether a custom module is the expected answer.
Has the Magento connector been run against a real Magento store?
Not against a live production instance — no Svelte Commerce connector has been. It was written by reading Magento’s authoritative API source, and the Svelte Commerce maintainers ask Magento’s own maintainers for a sandbox to run it against.
Sources
This page summarises MAGENTO.md in the Svelte Commerce repository and the Magento 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. Magento 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. MAGENTO.md has the Magento setup in full, beside the connector’s source.