Svelte Commerce × Bagisto

Svelte Commerce on Bagisto

Solid core coverage: cart, checkout and sign-in are wired against Bagisto’s REST API. Bagisto chooses the channel by the request’s host, and takes locale and currency as headers.

What works on Bagisto today

Cart, checkout and sign-in are wired; coupons, CMS pages, payment-method listing and vendors are not.

Cart

Wired: issues a real request to Bagisto.

Checkout

Wired: issues a real request to Bagisto.

Sign-in (auth)

Wired: issues a real request to Bagisto.

Known gaps: coupon, page, payment-method, vendor

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

What the connector calls on Bagisto

The connector calls the bagisto/rest-api package’s plain-JSON REST API under /api/v1, checked against its tag v2.3.1, and not Bagisto’s GraphQL API or the API Platform package that api-docs.bagisto.com documents.

The shopper signs in with POST /api/v1/customer/login (email, password, device_name), and the Laravel Sanctum token it returns is kept in the connector’s shared credentials and sent as Authorization: Bearer on every later call; there is no cookie, no CSRF token and no refresh token, so a 401 means signing in again.

Requests the @misiki/bagisto-connector source makes, by storefront service
ServiceWhat it requests
productGET /api/v1/products with query, category_id, url_key, featured, sort and page; GET /api/v1/products/{id}, plus GET /api/v1/products/{id}/configurable-config for a configurable product’s variants
categoryGET /api/v1/categories (with pagination=0&status=1 to resolve a slug) and GET /api/v1/categories/{id} by numeric ID
searchGET /api/v1/products with query, category_id and price=min,max; GET /api/v1/categories/max-price/{id} for the price ceiling
cartGET /api/v1/customer/cart, POST /api/v1/customer/cart/add/{productId}, PUT /api/v1/customer/cart/update with { qty: { <cartItemId>: <quantity> } }, DELETE /api/v1/customer/cart/remove/{cartItemId}, and POST or DELETE /api/v1/customer/cart/coupon
checkoutPOST /api/v1/customer/checkout/save-address, save-shipping, save-payment ({ payment: { method } }), check-minimum-order and save-order
orderGET /api/v1/customer/orders (with increment_id to find one order by number) and GET /api/v1/customer/orders/{id}
authPOST /api/v1/customer/login, POST /api/v1/customer/register, GET /api/v1/customer/get, PUT /api/v1/customer/profile, POST /api/v1/customer/forgot-password and POST /api/v1/customer/logout
addressGET, POST, PUT and DELETE on /api/v1/customer/addresses, and PATCH /api/v1/customer/addresses/make-default/{id}

Bagisto rules the connector follows

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

Quick start

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

Clone it, choose the connector, point it at Bagisto

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

# 3 — point it at your Bagisto channel
echo PUBLIC_BAGISTO_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 Bagisto
VariableRequiredWhat it does
PUBLIC_BAGISTO_API_URLYesYour Bagisto URL. Bagisto picks the channel by matching the request’s host, so point this at the channel’s hostname. Boot fails, naming this variable, if it is missing.
PUBLIC_BAGISTO_ACCESS_TOKENNoA Sanctum token, sent as a bearer token when set.
PUBLIC_BAGISTO_LOCALENoSent as x-locale; an unknown value falls back to the channel default.
PUBLIC_BAGISTO_CURRENCYNoSent as x-currency; an unknown value falls back to the channel default.
PUBLIC_CONNECTORNoOnly when more than one connector is installed: @misiki/bagisto-connector names the one this build runs on.

init.ts hands the connector every PUBLIC_BAGISTO_* variable that is set, camel-cased. The guide also lists PUBLIC_BAGISTO_STORE_ID and PUBLIC_BAGISTO_CHANNEL_ID, which have no effect over Bagisto’s REST API — the channel comes from the host — and PUBLIC_BAGISTO_API_KEY, PUBLIC_BAGISTO_API_SECRET and PUBLIC_BAGISTO_ACCESS_KEY, which the connector’s source does not read.

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 Bagisto

How the integration works

Bagisto has no channel header or parameter: it matches the request’s host against its channels’ hostnames. Locale and currency travel as the x-locale and x-currency headers, and signed-in shoppers carry a Sanctum bearer token. The storefront also ships a /proxy/bagisto/* route that forwards to PUBLIC_BAGISTO_API_URL.

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 Bagisto

Can I run a Bagisto store on Svelte Commerce today?

Cart, checkout and sign-in are wired; coupons, CMS pages, payment-method listing and vendors are not. Like every connector, it has not been run against a live production Bagisto store.

How do I switch Svelte Commerce to Bagisto?

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

How do I choose a Bagisto channel, locale or currency?

The channel by host: point PUBLIC_BAGISTO_API_URL at the channel’s hostname. Locale and currency by variable: PUBLIC_BAGISTO_LOCALE and PUBLIC_BAGISTO_CURRENCY travel as the x-locale and x-currency headers, and unknown values fall back to the channel default.

Sources

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

Read the whole guide

Chat on WhatsApp