Svelte Commerce × Spryker

Svelte Commerce on Spryker

Spryker’s storefront API speaks JSON:API, and the connector wires browsing, cart, sign-in and Spryker’s checkout data. The storefront cannot place an order on it yet: Spryker has no per-gateway checkout, and the storefront asks for one.

What works on Spryker today

Browsing, cart and sign-in are wired, but the storefront cannot complete an order yet. Spryker has two checkout endpoints and no per-gateway ones, with payment methods named per store. The connector offers getCheckoutData() and placeOrder() for that, but the storefront’s payment step calls one method per gateway — cash on delivery included — and each of those is a placeholder.

Cart

Wired: issues a real request to Spryker.

Checkout

Wired: issues a real request to Spryker.

Sign-in (auth)

Wired: issues a real request to Spryker.

Known gaps: coupon

25 of 43 services wired, read from CONNECTORS.md on ; npm may carry a newer patch. How coverage is measured.

What the connector calls on Spryker

The connector calls Spryker’s Glue Storefront API, a JSON:API surface with no path prefix (/catalog-search, /abstract-products/{sku}, /carts, /checkout and so on hang off the configured host), and only its POST /token route takes form-encoded input and answers in flat JSON.

A shopper signs in with an OAuth password grant to POST /token, sent as application/x-www-form-urlencoded, and the access token is then sent as Authorization: Bearer <token> and renewed once with the refresh token when a call answers 401; a guest is identified only by X-Anonymous-Customer-Unique-Id, which the connector mints itself and keeps in localStorage and a cookie.

Requests the @misiki/spryker-connector source makes, by storefront service
ServiceWhat it requests
productGET /catalog-search with q, page, ipp, sort and category for lists, and GET /abstract-products/{sku}?include=concrete-products,abstract-product-image-sets,abstract-product-prices,abstract-product-availabilities for one product, after GET /url-resolver?url= turns a slug into the SKU
searchGET /catalog-search for results and GET /catalog-search-suggestions?q= for typeahead
categoryGET /category-trees and GET /category-nodes/{nodeId}, with GET /url-resolver?url= for a category slug
cartGET /carts or /guest-carts with include=items or guest-cart-items, POST /carts/{uuid}/items or POST /guest-cart-items, PATCH on {root}/{uuid}/{items|guest-cart-items}/{groupKey}, and POST {root}/{uuid}/vouchers
payment-methodPOST /checkout-data?include=payment-methods for the current cart, since there is no standalone payment-methods route
authPOST /token (grant_type=password), then GET /customers for the profile; POST /customers to register and DELETE /refresh-tokens/{token} on sign-out
orderGET /orders with page[offset] and page[limit], and GET /orders/{id}
addressGET, PATCH and DELETE on /customers/{customerReference}/addresses and /customers/{customerReference}/addresses/{id}

Spryker rules the connector follows

Read from the source of misiki-in/spryker-connector at commit 0778226 of . Where the code has changed since, the code is right.

Quick start

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

Clone it, choose the connector, point it at Spryker

# 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/spryker-connector

# 3 — point it at your Spryker Glue API
echo PUBLIC_SPRYKER_API_URL=https://your-store.example.com >> .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 Spryker
VariableRequiredWhat it does
PUBLIC_SPRYKER_API_URLYesBase URL of your Spryker Glue storefront API. Boot fails, naming this variable, if it is missing.
PUBLIC_SPRYKER_STORE_IDNoThe Spryker store name, sent as the Store header — DE, for example — for Dynamic Multistore.
PUBLIC_SPRYKER_LOCALENoSent as Accept-Language, such as de_DE.
PUBLIC_SPRYKER_ANONYMOUS_CUSTOMER_IDNoA guest identity replayed as X-Anonymous-Customer-Unique-Id. The browser mints its own; this exists for server rendering.
PUBLIC_SPRYKER_NAVIGATION_KEYNoThe key for GET /navigations/{key}: Spryker has no route that lists navigations.
PUBLIC_SPRYKER_ACCESS_TOKENNoSent as a bearer token when set.
PUBLIC_CONNECTORNoOnly when more than one connector is installed: @misiki/spryker-connector names the one this build runs on.

init.ts hands the connector every PUBLIC_SPRYKER_* variable that is set, camel-cased: PUBLIC_SPRYKER_ANONYMOUS_CUSTOMER_ID arrives as anonymousCustomerId. The guide also lists PUBLIC_SPRYKER_API_KEY, PUBLIC_SPRYKER_API_SECRET, PUBLIC_SPRYKER_ACCESS_KEY and PUBLIC_SPRYKER_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 Spryker

How the integration works

Spryker’s Glue storefront API answers in JSON:API, and the connector ships a deserialiser that resolves included relationships (the jsonapi file in its source is that helper, not a service). The store travels as a Store header, the locale as Accept-Language, and a guest as X-Anonymous-Customer-Unique-Id.

Checkout in Spryker is two calls: POST /checkout-data, which says what is still missing and which payment and shipment methods this cart can use, and POST /checkout, which places the order. Payment is chosen by method and provider names configured per store. The connector wires both as getCheckoutData() and placeOrder(); the storefront’s per-gateway methods stay placeholders, because inventing them would mean guessing a store’s payment method names.

Limitations on Spryker

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.

Offer a sandbox or a correction

FAQ

Questions about Svelte Commerce on Spryker

Can I run a Spryker store on Svelte Commerce today?

Not to take orders. Browsing, cart and sign-in are wired, but the storefront’s payment step calls per-gateway methods that are placeholders on Spryker. The connector has the Spryker-native getCheckoutData() and placeOrder(); the storefront does not call them yet.

How do I switch Svelte Commerce to Spryker?

Remove the connectors the storefront ships with, install @misiki/spryker-connector, set PUBLIC_SPRYKER_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 can’t Svelte Commerce place an order on Spryker?

Spryker has exactly two checkout endpoints — one to check what is missing, one to place the order — and chooses payment by names each store configures. The storefront expects one method per gateway, and inventing those would mean guessing a store’s payment method names, so the connector leaves them as placeholders.

Sources

SPRYKER.md, read on ; CONNECTORS.md, read on ; the connector’s source at 0778226. Where they disagree with this page, they are right. Spryker is a trademark of its owner, named only to describe compatibility; see trademarks.

Read the whole guide

Chat on WhatsApp