E-commerce headless components for building cart, checkout, and commerce functionality in Wix-powered applications.
npm install @wix/headless-ecomE-commerce headless components for building cart, checkout, and commerce functionality in Wix-powered applications.
Traditional Wix components are tightly coupled with Wix's editor and rendering engine. Headless components break free from this constraint, enabling developers to build completely custom frontends while still leveraging Wix's powerful backend services.
This package connects your standalone React application (Next.js, Astro, Remix, etc.) directly to Wix's e-commerce APIs through the Wix SDK.
In simple words - the developer brings the UI, Wix provides the e-commerce engine. The headless components are the bridge that connects them, giving the developer the best of both worldsβWix's robust backend with his frontend creativity.
This package provides unstyled, composable React components for e-commerce functionality, following a service-oriented architecture where business logic is separated from presentation.
For detailed API specifications, see ECOM_INTERFACE.md.
``bash`
npm install @wix/headless-ecom @wix/headless-componentsor
yarn add @wix/headless-ecom @wix/headless-components
- Cart - Main cart component with primitive layer and AsChild support
- LineItem - Individual cart item component
- CartCoupon - Coupon management functionality
- SelectedOption - Product options displayed in cart
- CurrentCart - Cart state wrapper component
- Commerce - Commerce functionality wrapper
- CurrentCartService - Cart state management
- CheckoutService - Checkout flow logic
- SelectedOptionService - Product option handling
`tsx
import { Cart } from '@wix/headless-ecom/react';
import { LineItem } from '@wix/headless-ecom/react';
function ShoppingCart() {
return (
{({ lineItems, isLoading }) =>
isLoading ? (
Loading cart...
) : (
lineItems.map((item) => (
))
)
}
Subtotal: {subtotal} Tax: {tax} Total: {total}
{({ subtotal, total, tax }) => (
)}
{({ checkout, isLoading }) => (
)}
);
}
`
`tsx
import {
CurrentCartService,
loadCurrentCartServiceConfig,
} from '@wix/headless-ecom/services';
// Load cart configuration
const config = await loadCurrentCartServiceConfig();
// Use in your service manager
const services = createServiceManager({
services: [CurrentCartService],
config: { currentCart: config },
});
`
This package follows a three-layer architecture:
Business logic, state management, and API integrations:
- current-cart-service.ts - Cart state and operationscheckout-service.ts
- - Checkout flow managementselected-option-service.ts
- - Product option handlingcommon-types.ts
- - Shared TypeScript types
Headless UI primitives with render props:
- Core Components (/react/core) - Plain render functions connecting directly to the SDK. These use the old render-props pattern and provide the foundational logic for interacting with Wix services./react
- Public API Components () - Primitive components inspired by Radix UI. These wrap the core components to provide a more modern, composable API with asChild support and follow the documented patterns.
Key Principle: Headless components include no styling and preferably minimal DOM elements. They are designed to be building blocks for composing the UI of your e-commerce app, giving the developer complete control over the visual presentation while handling all the business logic, state management, and API interactions.
Data transformation utilities:
- line-item-to-selected-options.ts - Convert line items to selected options
``
ecom/
βββ package.json
βββ README.md (this file)
βββ tsconfig.*.json
βββ vitest.config.ts
βββ src/
β βββ react/
β β βββ Cart.tsx (1,246 lines - main component)
β β βββ Cart.test.tsx
β β βββ LineItem.tsx
β β βββ LineItem.test.tsx
β β βββ SelectedOption.tsx
β β βββ SelectedOption.test.tsx
β β βββ CartCoupon.tsx
β β βββ CartCoupon.test.tsx
β β βββ CurrentCart.tsx
β β βββ Commerce.tsx
β β βββ Commerce.test.tsx
β β βββ index.tsx
β β βββ core/
β β βββ CurrentCart.tsx (old render-props)
β β βββ Checkout.tsx
β βββ services/
β β βββ current-cart-service.ts
β β βββ checkout-service.ts
β β βββ selected-option-service.ts
β β βββ common-types.ts
β β βββ index.ts
β βββ mappers/
β β βββ line-item-to-selected-options.ts
β βββ data-component-tags.ts
βββ dist/ (built ESM output)
βββ cjs/ (built CommonJS output)
`bashInstall dependencies (from monorepo root)
yarn install
$3
β οΈ Important: Always use
--run flag to avoid interactive watch mode.`bash
Run tests (non-interactive)
yarn test --runRun tests with verbose output
yarn test --run --reporter=verboseRun tests with coverage
yarn test --run --coverage
`$3
`bash
Build both ESM and CommonJS
yarn buildBuild ESM only
yarn build:esmBuild CommonJS only
yarn build:cjs
`$3
`bash
Lint and fix
yarn lint:fixLint check (no changes)
yarn lint:check
`π Design Patterns
$3
This package follows the standard three-level architecture for list-based components:
`tsx
// Level 1: Container - provides context, conditional rendering
// Level 2: List container - handles empty state
Your cart is empty $3
Components support the
asChild prop for custom DOM structure:`tsx
// Default rendering
Product Name
// Renders: Product Name// With asChild - merges with child element
Product Name
// Renders:
Product Name
`$3
All components use centralized TestIds enums:
`tsx
enum TestIds {
cartRoot = 'cart-root',
cartLineItems = 'cart-line-items',
cartItem = 'cart-item',
cartSummary = 'cart-summary',
}// Usage in tests
screen.getByTestId('cart-root');
`π Deployment
This section describes how to roll out changes from the headless components package into the full Wix ecosystem (stores extension, kitchensink, Vibe plugins, and production extensions).
> βΉοΈ Note: These steps are internal to Wix and assume access to the relevant private repositories and Falcon publishing.
---
$3
1. Add your code changes to the headless components monorepo:
@wix/headless-ecom / @wix/stores in
https://github.com/wix-private/headless-components/tree/master/packages/headless-components/stores
2. Open a PR, get it reviewed, and merge into master.
3. Wait for Falcon to build and publish the new package version to the internal registry.---
$3
Update the Stores extension to re-export the newly published version of
@wix/stores:- Bump the consumed version to the newly published one.
---
$3
Update the kitchensink demo app to use the new version of
@wix/stores:1. In https://github.com/wix-incubator/kitchensink, bump the
@wix/stores version.
2. Modify wrapper components or examples if API changes affect them.
3. Open a PR and merge it into master once tests pass.---
$3
1. In
vibe-stores-plugin-files, run the kitchen-sync script to pull the updated files from kitchensink.
2. Open a PR containing the generated updates.
3. In the same PR, bump the plugin version in:
https://github.com/wix-private/vibe-plugins/blob/master/plugins/stores/vibe-stores-plugin/package.json#L3---
$3
When the updated
@wix/vibe-stores-plugin version is published:1. Go to the extension in your app in dev center:
2. Update the Store plugin version in the extension to the newly published one.
3. Publish the extension.
---
π Dependencies
$3
`json
{
"@wix/auto_sdk_ecom_checkout": "^1.0.61",
"@wix/auto_sdk_ecom_current-cart": "^1.0.56",
"@wix/headless-media": "workspace:*",
"@wix/sdk": "^1.15.24",
"@wix/services-manager-react": "^0.1.26",
"@radix-ui/react-slot": "^1.1.0"
}
`$3
`json
{
"@wix/headless-components": "^0.0.0"
}
`π Package Exports
This package exports both ESM and CommonJS formats:
`json
{
"exports": {
"./react": {
"types": "./dist/react/index.d.ts",
"import": "./dist/react/index.js",
"require": "./cjs/dist/react/index.js"
},
"./services": {
"types": "./dist/services/index.d.ts",
"import": "./dist/services/index.js",
"require": "./cjs/dist/services/index.js"
}
}
}
`π Related Documentation
- Main README:
/packages/headless-components/README.md - Architecture guidelines
- Implementation Status: /docs/IMPLEMENTATION_STATUS.md - Complete component checklist
- API Documentation: /docs/api/ECOM_INTERFACE.md - E-commerce API specifications
- Contributing: /CONTRIBUTING.md - Contribution guidelinesπ Examples
Check out these example projects using this package:
-
examples/astro-stores-demo/ - Complete store implementation
- examples/astro-restaurants-olo-demo/` - Online ordering with cart