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.
- 22/43 services wired
- @misiki/bagisto-connector 0.4.0
- Cart wired
- Checkout wired
- Sign-in (auth) wired
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.
| Service | What it requests |
|---|---|
product | GET /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 |
category | GET /api/v1/categories (with pagination=0&status=1 to resolve a slug) and GET /api/v1/categories/{id} by numeric ID |
search | GET /api/v1/products with query, category_id and price=min,max; GET /api/v1/categories/max-price/{id} for the price ceiling |
cart | GET /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 |
checkout | POST /api/v1/customer/checkout/save-address, save-shipping, save-payment ({ payment: { method } }), check-minimum-order and save-order |
order | GET /api/v1/customer/orders (with increment_id to find one order by number) and GET /api/v1/customer/orders/{id} |
auth | POST /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 |
address | GET, POST, PUT and DELETE on /api/v1/customer/addresses, and PATCH /api/v1/customer/addresses/make-default/{id} |
Bagisto rules the connector follows
- Bagisto’s generic list controller turns every query parameter other than
page,limit,pagination,sort,orderandtokeninto awhereInon the table, so an unknown name is an SQL 500; the connector sends only those keys to/categories,/customer/ordersand/customer/addresses, and resolves a category slug in the browser because slugs live incategory_translations. /api/v1/productsaccepts onesorttoken from a fixed list (name-asc,name-desc,created_at-asc,created_at-desc,price-asc,price-desc) and clampslimitto the store’s products-per-page setting, so the connector maps the storefront’s sort to one of those tokens and reads page size and totals from Laravel’s paginatormeta, never from the size it asked for.- The cart has no ID: every cart route resolves it from the signed-in customer, so the Sanctum token is the cart identity and a shopper who is not signed in gets a 401.
- Bagisto has no payment-methods route; the list arrives only in the response to
save-shipping, andsave-orderfails unlesssave-paymenthas run first, so the connector places a cash-on-delivery order with the corecashondeliverymethod code. - An
etagmiddleware answers a revalidating GET with 304, which the connector treats as an empty success rather than an error, and a 404 with no message is reported as the REST API package not being installed on the store.
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
| Variable | Required | What it does |
|---|---|---|
PUBLIC_BAGISTO_API_URL | Yes | Your 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_TOKEN | No | A Sanctum token, sent as a bearer token when set. |
PUBLIC_BAGISTO_LOCALE | No | Sent as x-locale; an unknown value falls back to the channel default. |
PUBLIC_BAGISTO_CURRENCY | No | Sent as x-currency; an unknown value falls back to the channel default. |
PUBLIC_CONNECTOR | No | Only 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
- Point
PUBLIC_BAGISTO_API_URLat the hostname of the channel you want to sell from: Bagisto matches the request’s host against its channels’ hostnames, falling back to the first channel.
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 correctionFAQ
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.