@appmate/wishlist-hydrogen

中文文档
2.2.0发布于 2024/06/14UNLICENSEDTypeScriptES Module近 30 天下载 2772

Wishlist King SDK for Shopify Hydrogen

原始使用文档
文档目录5 节
  1. Create Client
  2. Add Components
  3. Add Wishlist Provider
  4. Create Wishlist Route
  5. Render Wishlist Components

Wishlist King SDK for Shopify Hydrogen

Integrate Wishlist King into your Shopify Hydrogen project.

Install package with npm i @appmate/wishlist-hydrogen.

Create Client

Setup a Wishlist King client in server.ts.

// Create a client
const { wishlistKing } = createWishlistClient({
  shopDomain: "your-domain.myshopify.com",
  // Make sure your session stores the customer id.
  customerId: session.get("customerId"),
  cache: caches.open("wishlist-king"),
  request,
  waitUntil,
});

// Add client to request handler
const handleRequest = createRequestHandler({
  build: remixBuild,
  mode: process.env.NODE_ENV,
  getLoadContext: () => ({
    // Keep your current context and add wishlistKing
    wishlistKing,
  }),
});

Add type definition in remix.env.d.ts.

declare module "@shopify/remix-oxygen" {
  export interface AppLoadContext {
    // ...
    wishlistKing: WishlistClient;
  }
}

Add Components

Copy file components/WishlistButton.tsx from examples.

Copy file components/WishlistGrid.tsx from examples.

Copy file components/WishlistLink.tsx from examples.

Add Wishlist Provider

Render your main layout inside the WishlistProvider.

<WishlistProvider>{/* Add your layout here */}</WishlistProvider>

Create Wishlist Route

Copy file routes/($locale).wishlists.$wishlistHandle.tsx from examples.

Render Wishlist Components

Render WishlistLink in header.

<WishlistLink />

Render WishlistButton on product page.

<WishlistButton productId={product.id} variantId={selectedVariant?.id} />

版本与发布记录

@appmate/wishlist-hydrogen 共发布 7 个版本,首次发布于 2023/10/31;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.2.0latest2024/06/142 年前
2.1.02024/05/232 年前
2.0.02024/05/142 年前
1.0.72023/10/313 年前
1.0.62023/10/313 年前
1.0.52023/10/313 年前

关于 @appmate/wishlist-hydrogen 的常见问题

@appmate/wishlist-hydrogen 是什么?

Wishlist King SDK for Shopify Hydrogen

如何安装 @appmate/wishlist-hydrogen?

在项目目录运行 npm install @appmate/wishlist-hydrogen,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@remix-run/react(>= 2.0.0)、@shopify/oxygen-workers-types(>= 3.0.0)、@shopify/remix-oxygen(>= 2.0.0)、react(>= 18.0.0)、react-dom(>= 18.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@appmate/wishlist-hydrogen 支持 TypeScript 吗?

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

@appmate/wishlist-hydrogen 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@appmate/wishlist-hydrogen 可以商用吗?

@appmate/wishlist-hydrogen 使用 UNLICENSED 许可。作者声明为 UNLICENSED,即不授予公开使用许可(与公共领域的 Unlicense 不同)。使用前需获得作者授权。以上为概括,不构成法律意见,请以许可原文为准。

@appmate/wishlist-hydrogen 的下载量有多少?

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

@appmate/wishlist-hydrogen 还在维护吗?

最新版本 2.2.0 发布于 2024/06/14(2 年前);至今共发布 7 个版本,其中过去 12 个月发布了 0 个;首次发布于 2023/10/31。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。