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.

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.

Requests the @misiki/magento-connector source makes, by storefront service
ServiceWhat it requests
productGET /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
categoryGET /V1/categories/list filtered on is_active and level, or on url_key to resolve a slug; GET /V1/categories/{id} for one category
searchGET /V1/search with search_term and searchCriteria[requestName], then GET /V1/products filtered on entity_id in the returned IDs
cartPOST /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
checkoutPOST {cart}/shipping-information, GET {cart}/payment-methods to resolve a method code, then POST {cart}/payment-information to place the order
orderGET /V1/orders with searchCriteria filters on customer_id, customer_email, status or increment_id, and GET /V1/orders/{id}, both with the admin token
authPOST /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
addressGET /V1/customers/me, then PUT /V1/customers/me with the whole customer and its edited addresses array

Magento rules the connector follows

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

What Svelte Commerce reads to reach Magento
VariableRequiredWhat it does
PUBLIC_MAGENTO_API_URLYesYour Magento base URL; the connector builds {url}/rest[/{store_code}]/V1. Boot fails, naming this variable, if it is missing.
PUBLIC_MAGENTO_ACCESS_TOKENNoAn 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_IDNoA store view code, such as default, used to scope requests. Used only when it looks like a code rather than a numeric ID.
PUBLIC_CONNECTORNoOnly 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

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

Troubleshooting Magento

Errors particular to Svelte Commerce on Magento, and what fixes them
When you seeWhat to do
Every catalogue call returns 401On 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 correction

FAQ

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.

Read the whole guide

Chat on WhatsApp