@adobe/aem-core-cif-react-components

中文文档
2.19.2发布于 2026/10/05Apache-2.0ESM + CJS零依赖近 30 天下载 3322

A collection of React components used in the AEM CIF Core Components project

原始使用文档
文档目录21 节
  1. Reducing bundle size
  2. Deprecated components
  3. Components related to the shopping cart
  4. Cart
  5. CartProvider
  6. CartInitializer
  7. CheckoutProvider
  8. Components related to user authentication / account managem…
  9. AuthBar
  10. AccountContainer
  11. AddressBook
  12. UserContextProvider
  13. General purpose components
  14. CommerceApp
  15. graphqlAuthLink
  16. Portal
  17. Building the project
  18. Testing the components
  19. Development
  20. Prerequisites
  21. Building

CIF Core Components - React Components

The React Components project is the code base for all the CIF Core Components built using React. The following components are exposed by this library:

Reducing bundle size

This package supports tree-shaking — your storefront only bundles the components you actually import.

Named imports (recommended):

import { CommerceApp, Portal, ConfigContextProvider } from '@adobe/aem-core-cif-react-components';

Direct import for a single component:

import GiftCartOptions from '@adobe/aem-core-cif-react-components/dist/esm/components/GiftCardOptions';

Paths under dist/esm/ mirror the src/ folder structure.

Tips:

  • Use named imports — avoid import * or importing the whole package
  • Run a production build (webpack -p / npm run prod) so unused code is removed
  • Only import the components you use on each page
  • No webpack configuration changes are required

Deprecated components

The following cart, checkout, and account components are deprecated.

CategoryDeprecated
Cart & checkoutCart, CartTrigger, CartProvider, CartInitializer, useCartState, CheckoutProvider
Account & authAuthBar, AccountContainer, AddressBook, ResetPassword, MyAccount, AccountLink, AccountDetails, UserContextProvider, useUserContext
UtilityTrigger

Cart

An implementation of the "minicart" component, complete with checkout experience.

CartProvider

A context provider for a cart component which provides state management for cart operations

CartInitializer

A component which provides cart operations such as "Add to cart" and "Remove from cart"

CheckoutProvider

A context provider for a cart component which provides state management for checkout operations

AuthBar

The account management components - Sign In, Forgot Password, Change Password and My Account, all wrapped into one component

AccountContainer

The same as AuthBar, but rendered in a dropdown instead of a panel.

AddressBook

A component that allows authenticated shoppers to manage their address books.

UserContextProvider

A context provider for user operations - sign in / sign-out, create user

General purpose components

CommerceApp

A convenience wrapper for React components, encapsulating all the required contexts to run the app

An ApolloLink instance that handles authorization on certain graphql requests (e.g.: cart mutations). This is intended to be used when creating a new ApolloClient instance:

import { ApolloClient, from, HttpLink, InMemoryCache } from '@apollo/client';
import { graphqlAuthLink } from '@adobe/aem-core-cif-react-components';

const client = new ApolloClient({
    link: from([graphqlAuthLink, new HttpLink({ uri: graphqlEndpoint, headers: { Store: storeView } })]),
    cache: new InMemoryCache()
});

Portal

A component that allows rendering a React tree inside of a Portal. Uses ReactDOM.createPortal() under the hood.

Building the project

The project is built using the command npm run build. The build process bundles all the code into one client library which is placed in ../ui.apps/src/main/content/jcr_root/apps/core/cif/clientlibs/react-components/dist.

Testing the components

This project uses Jest for running unit tests and React Testing Library as the testing framework. This framework allows you to test the behavior of the components rather than the implementations.

The unit tests are run using the npm run test command. To run the tests during development you can use npm run test:watch to start Jest in watch mode.

Development

Prerequisites

For development, please have node.js (v12+) and npm (v6+) installed.

The React components access the Magento GraphQL endpoint directly, so all calls have to either be served from the same endpoint as AEM or served via a proxy that adds CORS headers.

To start a local proxy server, you can use the following command:

npx local-cors-proxy --proxyUrl https://my.magento.cloud --port 3002 --proxyPartial ''

The GraphQL endpoint is then available at http://localhost:3002/graphql.

If you develop for AEM on-prem installations, a proxy is included in our sample Dispatcher configuration (see the dispacher configuration for details). You have to access AEM through the dispatcher (i.e. use https://localhost instead of http://localhost:4502).

Building

To build the components you can use

npm run build

版本与发布记录

@adobe/aem-core-cif-react-components 共发布 65 个版本,首次发布于 2019/11/29;过去 12 个月发布了 9 个版本。

版本发布日期距今
2.19.2latest2026/10/051 个月前
2.19.02026/10/011 个月前
2.18.82026/08/112 个月前
2.18.62026/08/112 个月前
2.18.42026/05/195 个月前
2.18.22026/03/317 个月前

关于 @adobe/aem-core-cif-react-components 的常见问题

@adobe/aem-core-cif-react-components 是什么?

A collection of React components used in the AEM CIF Core Components project

如何安装 @adobe/aem-core-cif-react-components?

在项目目录运行 npm install @adobe/aem-core-cif-react-components,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(~17.0.1)、graphql(~15.7.2)、informed(~3.29.4)、react-dom(~17.0.1)、prop-types(^15.7.2)、react-intl(~5.20.0)、react-feather(^2.0.3)、@apollo/client(^3.1.2)、@magento/peregrine(^11.0.0 || ~12.5.0)、braintree-web-drop-in(^1.22.1)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@adobe/aem-core-cif-react-components 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/adobe__aem-core-cif-react-components 是否存在。

@adobe/aem-core-cif-react-components 支持 ESM 还是 CommonJS?

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

@adobe/aem-core-cif-react-components 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=12。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@adobe/aem-core-cif-react-components 可以商用吗?

@adobe/aem-core-cif-react-components 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@adobe/aem-core-cif-react-components 的下载量有多少?

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

@adobe/aem-core-cif-react-components 还在维护吗?

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