@apollosproject/canvas-embeds

中文文档
2.1.2951发布于 2026/11/07MITESM + CJS近 30 天下载 6.4万

Apollos React embed widgets

原始使用文档
文档目录14 节
  1. Getting Started with Apollos Embeds
  2. 1. Adding Script Tags to Your Website
  3. 3. Understanding Embed Modes
  4. 4. Add Embed Containers
  5. 5. Customizing Embeds with Attributes
  6. 6. Understanding Church Slugs
  7. For Developers
  8. Background
  9. How It Works
  10. Local Development
  11. Publishing Updates / Cache Busting
  12. Caching
  13. jsDelivr Cache Busting
  14. Advanced Configuration

Apollos Embeds

Apollos React Embeds are pre-built, reusable components designed to integrate seamlessly into third-party websites such as Webflow. These widgets provide functionality for authentication, content feeds, and search features, creating a unified and engaging user experience across platforms.


Getting Started with Apollos Embeds

1. Adding Script Tags to Your Website

To enable the Apollos Embeds, include the following scripts and stylesheets in your website's code. For Webflow users, add them to the Custom Code section under Footer Code:

<link
  rel="stylesheet"
  href="https://cdn.jsdelivr.net/npm/@apollosproject/canvas-embeds@latest/widget/index.css"
/>
<script
  defer
  src="https://cdn.jsdelivr.net/npm/@apollosproject/canvas-embeds@latest/widget/index.min.js"
></script>

3. Understanding Embed Modes

There are three primary modes in which Apollos Embeds can be used:

  • Apollos Site Mode
  • Container Mode
  • Legacy Modal Mode

Apollos Site Mode

In the Apollos Site Mode, all embeds link to the external Apollos site. This mode is recommended for users who want to maintain a consistent user experience across platforms, and it is the default mode for all embeds.

Container Mode

In the Container Mode, embeds are displayed within a container on the host website. This mode is recommended for users who want to keep users on their website while providing Apollos functionality. This mode also enables the user to cleanly integrate Apollos content into their website, while also applying custom styles.

To enable the Container Mode, add the data-apollos-path="/apollos" attribute to the script tag:

<script
  defer
  src="https://cdn.jsdelivr.net/npm/@apollosproject/canvas-embeds@latest/widget/index.min.js"
  data-apollos-route="/apollos"
></script>

On the host website, visiting any feed or content will navigate to the /apollos path on the host website. This path (which is customizable) should contain a div with the ID apollos-widget-container to display the embed content. This container should be styled to match the host website's design.

Legacy Modal Mode

In the Legacy Modal Mode, embeds are displayed in a modal window on the host website. This mode is recommended for users who want to keep users on their website while providing Apollos functionality. All embeds will be displayed in a modal window, with navigation state being tracked via URL search params.

To enable the Legacy Modal Mode, add the data-apollos-modal="true" attribute to the script tag:

<script
  defer
  src="https://cdn.jsdelivr.net/npm/@apollosproject/canvas-embeds@latest/widget/index.min.js"
  data-apollos-modal="true"
></script>

4. Add Embed Containers

Navigate to your site builder (e.g., Webflow) and add a div element for each embed you plan to use. Supported embeds:

  • Auth — user authentication
  • FeatureFeed — curated content feeds
  • Search — classic Algolia search and profile UI

Each div must include the apollos-widget class.

Example:

<!-- Auth -->
<div class="apollos-widget" data-type="Auth" data-church="example_church"></div>

<!-- FeatureFeed -->
<div
  class="apollos-widget"
  data-type="FeatureFeed"
  data-church="example_church"
></div>

<!-- Search (Algolia) -->
<div
  class="apollos-widget"
  data-type="Search"
  data-hide-apollos-auth="true"
  data-church="example_church"
  data-search-profile-size="365px"
></div>

Webflow embed example


5. Customizing Embeds with Attributes

Use data-attributes (or Custom Attributes in Webflow) to customize the behavior and appearance of each embed.

AttributeDescription
data-typeOne of: Auth, FeatureFeed, Search.
data-churchChurch slug (e.g., bayside).
data-search-profile-size(Search) Width of the profile modal.
data-hide-apollos-auth(Search) Hides the profile/auth UI.
data-feature-feed(FeatureFeed) ID of the feed to show.

Example for a FeatureFeed embed:

<div
  class="apollos-widget"
  data-type="FeatureFeed"
  data-church="example_church"
  data-feature-feed="FeatureFeed:unique-id"
  data-modal="true"
></div>

Auth embed attributes

FeatureFeed embed attributes


6. Understanding Church Slugs

Church slugs uniquely identify the organization whose content is displayed. If you're unsure of your slug, contact a developer or administrator.

[!NOTE] Replace [INSERT_CHURCH_SLUG_HERE] with your church's unique identifier (or slug). Contact a developer if you need assistance obtaining a church slug.


For Developers

Background

This package was originally part of the apollos-embeds repository and involved significant duplication of frontend code, components, and GraphQL queries. To unify our web frontend development, we created canvas-ui-web as a component library. The apollos-embeds project has been moved into this repository to coexist with our other web platforms.

The original version of web-embeds was heavily dependent on modal presentation. This new package retains selective use of modals while encouraging users to navigate to Apollos microsites, which run on New Web.

How It Works

Embeds are bundled as index.js and index.css in the /widget folder and distributed via jsDelivr. By including these on the webpage, users can access these embeds. Placing an apollos-widget div on the page triggers the web embed functionality.


Local Development

To work on this package locally, ensure you have a valid Feature Feed ID. Use index.html for testing with examples. Keep in mind that embeds from different churches on the same page may cause conflicts, so ensure you only use one church per page. You should be running apollos-cluster as well as this entire repo by running yarn dev.

Testing Embeds Locally

Use the index.html file for testing. Open http://localhost:5174 in your browser to view changes.

Example embed for testing:

<div
  data-type="FeatureFeed"
  data-church="apollos_demo"
  data-feature-feed="FeatureFeed:caf294f0-cd0e-4486-95e7-fa11bd5fb1c5"
  data-modal="true"
  class="apollos-widget"
></div>

To test changes, open http://localhost:5174 in your browser.


Publishing Updates / Cache Busting

This package is automatically deployed on merge to master. If you wish to manually deploy:

  1. cd apps/web-embeds
  2. Bump the version (patch by default): yarn bump (or yarn bump:minor / yarn bump:major). You may want to consult NPM to check on the last deployed version (it will be different than the version in package.json).
  3. Publish the package: npm publish --access public (automatically runs prepublishOnly/build)
  4. After npm shows the new version, purge jsDelivr so @latest updates immediately: yarn flush
  5. (Optional) Hit https://cdn.jsdelivr.net/npm/@apollosproject/canvas-embeds@latest/widget/index.js to verify the new bundle is served

Skipping the publish step means users will still download the previous version even if the repo contains newer code, and skipping the flush step delays propagation until jsDelivr expires its cache.


Caching

To test caching in local development, modify the Apollo client configuration by commenting out the x-cache-me-not header in:

src/client/apollosApiLink.js

'x-cache-me-not': 1,

jsDelivr Cache Busting

If you need to force jsDelivr to fetch the latest version of a file, you can manually purge the cache by accessing the purge subdomain of the file's URL. This command clears the cached version of the file from jsDelivr's CDN.

yarn flush

Advanced Configuration

Supported Embeds and Attributes

Embed TypeKey Attributes
Authdata-church
FeatureFeeddata-church, data-feature-feed
Searchdata-church, data-search-profile-size
data-hide-apollos-auth

Path Routing

For advanced routing options, use:

  • data-use-path-router="true" for enabling path-based routing.
  • data-apollos-id-param="true" for custom ID handling.

版本与发布记录

@apollosproject/canvas-embeds 共发布 2,951 个版本,首次发布于 2025/02/07;过去 12 个月发布了 2279 个版本。

版本发布日期距今
2.1.2951latest2026/11/07今天
2.1.29502026/11/07今天
2.1.29492026/11/07今天
2.1.29482026/11/07今天
2.1.29472026/11/07今天
2.1.29462026/11/07今天

关于 @apollosproject/canvas-embeds 的常见问题

@apollosproject/canvas-embeds 是什么?

Apollos React embed widgets

如何安装 @apollosproject/canvas-embeds?

在项目目录运行 npm install @apollosproject/canvas-embeds,或使用 pnpm add / yarn add / bun add。

@apollosproject/canvas-embeds 支持 TypeScript 吗?

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

@apollosproject/canvas-embeds 支持 ESM 还是 CommonJS?

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

@apollosproject/canvas-embeds 可以商用吗?

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

@apollosproject/canvas-embeds 的下载量有多少?

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

@apollosproject/canvas-embeds 还在维护吗?

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