Skip to content

Engine and theme

The code is an npm workspaces monorepo with two layers.

EngineConfigProvider

App Router pages

Components · UI primitives

magenx.config.ts

Apollo client

GraphQL documents + types
one folder per feature

Cart · wishlist · auth providers

Pricing · formatting · sanitising

packages/engine (@magenxcommerce/engine)apps/theme (a shop)

@magenxcommerce/engine is pure TypeScript and React, with no CSS and no visual opinions:

  • the Apollo client and its setup;
  • Magento GraphQL queries and types, one folder per feature under src/features/;
  • cart, wishlist and auth context providers;
  • tax-aware price selectors, HTML sanitising, recently-viewed products and cookie consent;
  • the server-only agentic-commerce handlers (UCP and ACP) under @magenxcommerce/engine/agentic/*.

It is published to npm. A shop pins the engine to an exact version, and releases move the pin, so a build always uses the engine its shop was tested with.

A shop is self-contained: pages, components, UI primitives and one config file, all inside apps/<shop>/. See Create a shop.

Engine code never imports a config file. The shop passes its config once, at the root layout:

apps/theme/src/app/[locale]/layout.tsx
import config from "#config"; // apps/theme/magenx.config.ts
<EngineConfigProvider config={config}>
<ApolloWrapper>
<AuthProvider>
<CartProvider>
<WishlistProvider>{children}</WishlistProvider>
</CartProvider>
</AuthProvider>
</ApolloWrapper>
</EngineConfigProvider>

Client components read it with hooks:

const { store, features, cms } = useEngineConfig();
const { brand, layout } = useThemeConfig(); // same object, wider type

Server components import #config directly.