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
26 of 43 services wired, read from CONNECTORS.md on ; npm may carry a newer patch. How coverage is measured.
What the connector calls on Magento
The connector calls Magento’s REST Web API at {url}/rest[/{store_code}]/V1, a single JSON namespace scoped to a store view code when one is set.
Every call carries Authorization: Bearer with a token chosen per route: the admin or integration token for catalogue, orders and CMS, the shopper’s customer token from POST /V1/integration/customer/token (kept in localStorage as customer_token) for /V1/customers/me and /V1/carts/mine, and no header at all for guest carts, search and the token endpoints.
| Service | What it requests |
|---|---|
product | GET /V1/products with searchCriteria[filter_groups], searchCriteria[sortOrders], searchCriteria[pageSize] and searchCriteria[currentPage]; GET /V1/products/{sku} for one product and GET /V1/configurable-products/{sku}/children for its variants |
category | GET /V1/categories/list filtered on is_active and level, or on url_key to resolve a slug; GET /V1/categories/{id} for one category |
search | GET /V1/search with search_term and searchCriteria[requestName], then GET /V1/products filtered on entity_id in the returned IDs |
cart | POST /V1/guest-carts or POST /V1/carts/mine to create the cart, then GET, GET /totals, POST /items, PUT and DELETE /items/{itemId} under the same prefix |
checkout | POST {cart}/shipping-information, GET {cart}/payment-methods to resolve a method code, then POST {cart}/payment-information to place the order |
order | GET /V1/orders with searchCriteria filters on customer_id, customer_email, status or increment_id, and GET /V1/orders/{id}, both with the admin token |
auth | POST /V1/integration/customer/token with username and password, POST /V1/customers to register, GET /V1/customers/me, PUT /V1/customers/me/password and POST /V1/integration/customer/revoke-customer-token |
address | GET /V1/customers/me, then PUT /V1/customers/me with the whole customer and its edited addresses array |
Magento rules the connector follows
- List routes need
searchCriteria, sosearchCriteria[currentPage]is always sent; filters inside one group are joined with OR and groups with AND, and the totals are read fromtotal_countin the body, because Magento sends no pagination headers. - Every cart route exists twice, under
/V1/guest-carts/{maskedId}with no token and under/V1/carts/minewith the customer token, and the connector picks the pair per session;POST /V1/guest-cartsanswers with the masked cart ID as a bare JSON string. - The quote carries no totals, so each cart read is two calls,
GET {cart}andGET {cart}/totals. - The store view code must be set for carts, because a cart created through the unscoped
/rest/V1/guest-cartsgetsstore_id0 and then rejects valid coupons; a numeric store ID is ignored rather than placed in the path. url_key, descriptions, images,special_priceand themeta_*fields are read from the product’scustom_attributesarray, not from top-level fields, and since Magento has noPATCH, updates are a read followed by a fullPUT.
Read from the source of misiki-in/magento-connector at commit fa8c39a of . Where the code has changed since, the code is right.
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 Switching works the same way on every backend: what all 26 share, from one connector at a time to store identity.
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.
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.
Limitations on Magento
- Reviews: not wired —
Magento_Reviewships nowebapi.xml, so there is no REST surface to call. - Wishlist: not wired —
Magento_Wishlistships nowebapi.xmleither. - 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.
Troubleshooting Magento
| 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. |
Before you rely on it
No connector has been exercised against a live production instance of its platform; each was written from the platform’s published source. The limits every backend shares and the errors every switch can meet are on the backends page.
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.
Sources
MAGENTO.md, read on ; CONNECTORS.md, read on ; the connector’s source at fa8c39a. Where they disagree with this page, they are right. Magento is a trademark of its owner, named only to describe compatibility; see trademarks.