Svelte Commerce × Sharetribe

Svelte Commerce on Sharetribe

Sharetribe is a marketplace, not a webshop, so the connector maps a listing to a product and a transaction to an order. There is deliberately no cart, no coupon and no category tree, and the storefront’s buying path is inert.

What works on Sharetribe today

Listings, sign-in and orders are wired, but the storefront cannot buy through it yet. Sharetribe has no cart and no checkout: buying is a transaction on one listing, moved through the marketplace’s own process, with money moving only through Stripe Connect. The connector ships Sharetribe-native transaction commands; the storefront’s cart and payment step do not use them, and its gateway methods throw NotSupportedError.

Cart

Not yet wired, by the coverage script’s measure.

Checkout

Wired: issues a real request to Sharetribe.

Sign-in (auth)

Wired: issues a real request to Sharetribe.

Known gaps: cart, coupon, address, country, state, wishlist

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

What the connector calls on Sharetribe

The connector calls three Sharetribe surfaces: the Marketplace API under /v1/api for every resource route, the Authentication API under /v1/auth for /token and /revoke only, and the Asset Delivery API under /v1/assets/pub/<client id> on a separate host for Console-managed content.

Every Marketplace API call carries Authorization: bearer <access_token>, because Sharetribe has no unauthenticated mode; before the first call the connector posts a form-encoded client_credentials grant with scope=public-read to /v1/auth/token, a shopper signs in with the password grant and scope=user, and the tokens are kept in the connector’s in-memory credentials, not in a cookie.

Requests the @misiki/sharetribe-connector source makes, by storefront service
ServiceWhat it requests
productGET /v1/api/listings/query with include=author,images,currentStock, fields.image, limit.images=4, page, perPage=24, keywords and sort; GET /v1/api/listings/show?id=<uuid>
categoryGET <asset host>/v1/assets/pub/<client id>/a/latest/listings/listing-categories.json for the tree; products by pub_categoryLevel1 on /listings/query
searchGET /v1/api/listings/query with keywords, pub_ and meta_ attribute filters and price=MIN,MAX
checkoutPOST /v1/api/transactions/initiate and initiate_speculative with processAlias, transition and params; POST /v1/api/transactions/transition; GET /v1/api/process_transitions/query
orderGET /v1/api/transactions/query and GET /v1/api/transactions/show?id=<uuid> with include=listing,provider,customer,booking,stockReservation
authPOST /v1/auth/token (password grant), then GET /v1/api/current_user/show; POST /v1/api/current_user/create to register; POST /v1/auth/revoke to sign out
payment-methodGET /v1/api/current_user/show?include=stripeCustomer,stripeCustomer.defaultPaymentMethod; POST /v1/api/stripe_customer/add_payment_method and delete_payment_method
reviewGET /v1/api/reviews/query with page and perPage

Sharetribe rules the connector follows

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

Quick start

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

Clone it, choose the connector, point it at Sharetribe

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

# 3 — point it at your Sharetribe marketplace
echo PUBLIC_SHARETRIBE_API_URL=https://your-store.example.com >> .env
echo PUBLIC_SHARETRIBE_CLIENT_ID=... >> .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 Sharetribe
VariableRequiredWhat it does
PUBLIC_SHARETRIBE_API_URLYesBase URL of the Marketplace API. Boot fails, naming this variable, if it is missing.
PUBLIC_SHARETRIBE_CLIENT_IDNoThe Marketplace API application’s client ID — the OAuth2 client_id, and the path segment the Asset Delivery API authenticates with. PUBLIC_SHARETRIBE_API_KEY is read in its place if it is unset.
PUBLIC_SHARETRIBE_API_KEYNoAccepted as the client ID when PUBLIC_SHARETRIBE_CLIENT_ID is unset.
PUBLIC_SHARETRIBE_API_SECRETNoThe client secret. See the limitations before setting it.
PUBLIC_SHARETRIBE_ACCESS_TOKENNoA user access token, sent as a bearer token. Every transaction call needs one.
PUBLIC_SHARETRIBE_ASSET_URLNoThe Asset Delivery API host, if it must be overridden. Defaults to https://cdn.st-api.com, a different host from the Marketplace API.
PUBLIC_CONNECTORNoOnly when more than one connector is installed: @misiki/sharetribe-connector names the one this build runs on.

init.ts hands the connector every PUBLIC_SHARETRIBE_* variable that is set, camel-cased. The guide also lists PUBLIC_SHARETRIBE_ACCESS_KEY, PUBLIC_SHARETRIBE_STORE_ID and PUBLIC_SHARETRIBE_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 Sharetribe

How the integration works

The connector maps Sharetribe’s model onto the storefront’s: a listing becomes a product, a transaction becomes an order. It also reads Sharetribe’s Asset Delivery API, which lives on a different host from the Marketplace API.

Buying on Sharetribe is initiating a transaction on one listing and moving it through the marketplace’s own transaction process, whose aliases and transitions are specific to each marketplace. The connector ships commands for that; it does not guess the process names, because a wrong guess fails. The storefront’s cart and per-gateway checkout have no Sharetribe equivalent, so they throw rather than return a fake receipt.

Limitations on Sharetribe

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 Sharetribe’s maintainers: Is listing to Product the mapping you would recommend, or should a storefront model transactions as the primary entity?

Offer a sandbox or a correction

FAQ

Questions about Svelte Commerce on Sharetribe

Can I run a Sharetribe marketplace on Svelte Commerce today?

Not to take bookings or sales. Listings, sign-in and orders are wired, but Sharetribe has no cart and no checkout, and the storefront’s buying path expects both. The connector has Sharetribe-native transaction commands; the storefront does not call them yet.

How do I switch Svelte Commerce to Sharetribe?

Remove the connectors the storefront ships with, install @misiki/sharetribe-connector, set PUBLIC_SHARETRIBE_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 is there no cart on Sharetribe?

Because Sharetribe does not have one. Buying is a transaction on a single listing, moved through the marketplace’s own process. The connector maps listings to products and transactions to orders, and leaves the cart and coupons deliberately empty. Its authors have asked Sharetribe’s maintainers whether that mapping is the one they would recommend.

Sources

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

Read the whole guide

Chat on WhatsApp