@commercelayer/react-components

中文文档
5.0.12发布于 2026/11/10MITTypeScriptESM + CJS构建来源已验证近 30 天下载 6162

The Official Commerce Layer React Components

原始使用文档
文档目录5 节
  1. What is Commerce Layer?
  2. Installation
  3. Authentication
  4. Need help?
  5. License

Commerce Layer React Components

A collection of reusable React components that makes it super fast and simple to build your own custom commerce UI, leveraging Commerce Layer API.

What is Commerce Layer?

Commerce Layer is a multi-market commerce API and order management system that lets you add global shopping capabilities to any website, mobile app, chatbot, wearable, voice, or IoT device, with ease. Compose your stack with the best-of-breed tools you already mastered and love. Make any experience shoppable, anywhere, through a blazing-fast, enterprise-grade, and secure API.

Getting started

For a constantly updated list of the available components, please refer to this interactive documentation that will provide you with all the necessary information about the involved web components and help you get started in a snap.

Installation

Commerce Layer React Components are available as an npm package:

// npm
npm install @commercelayer/react-components

// yarn
yarn add @commercelayer/react-components

// pnpm
pnpm add @commercelayer/react-components

Authentication

All requests to Commerce Layer API must be authenticated with an OAuth2 bearer token. Hence, to use these components, you need to get a valid access token. Once you got it, you can pass it as prop to the CommerceLayer component, as follow:

<CommerceLayer accessToken="your-access-token">

  {/* ... child components */}

</CommerceLayer>

Coming from v4? endpoint and domain are gone — v5 derives your organization from the token itself. See Upgrading from v4 for the full list of breaking changes.

This token will be used to authorize the API calls of all its child components. That's why the presence of (at least) one CommerceLayer component is mandatory — it must wrap every other component you need to use.

Please note that — in case you need to fetch data with different tokens (i.e. from different organizations or using apps with different roles and permissions) — nothing prevents you from putting as many CommerceLayer components you want in the same page.

You can check our documentation for more information about the available authorization flows and leverage Commerce Layer JS Auth to easily interact with our authentication API.

Need help?

License

This repository is published under the MIT license.

版本与发布记录

@commercelayer/react-components 共发布 645 个版本,首次发布于 2020/04/23;过去 12 个月发布了 58 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
5.0.12latest2026/11/10今天
5.0.112026/10/2714 天前
5.0.102026/10/1724 天前
5.0.92026/10/1625 天前
5.0.82026/10/1328 天前
5.0.72026/10/081 个月前

其他发布通道:alpha → 4.0.0-alpha.14,beta → 4.0.0-beta.3,next → 4.29.8-beta.1。

关于 @commercelayer/react-components 的常见问题

@commercelayer/react-components 是什么?

The Official Commerce Layer React Components

如何安装 @commercelayer/react-components?

在项目目录运行 npm install @commercelayer/react-components,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=19.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@commercelayer/react-components 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@commercelayer/react-components 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@commercelayer/react-components 可以商用吗?

@commercelayer/react-components 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@commercelayer/react-components 的下载量有多少?

根据 npm 官方下载统计,@commercelayer/react-components 在 2026/10/11 – 2026/11/09 这 30 天内被下载 6,162 次,日均约 205 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@commercelayer/react-components 还在维护吗?

最新版本 5.0.12 发布于 2026/11/10(今天);至今共发布 645 个版本,其中过去 12 个月发布了 58 个;首次发布于 2020/04/23。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。