@checkly/elements

中文文档
0.1.0-beta.2发布于 2026/10/16MITTypeScriptES Module近 30 天下载 2641

Embeddable Checkly monitoring UI as framework-agnostic custom elements

原始使用文档
文档目录8 节
  1. Install
  2. What is here
  3. Fetching Checkly data
  4. Scoped account-data pilot
  5. API keys are server side only
  6. Develop
  7. Documentation
  8. License

@checkly/elements

Embeddable Checkly monitoring UI as framework-agnostic custom elements — status, uptime, stats and incidents that can be dropped into any page regardless of the framework around it.

Browser-only and ES-only: loaded by a <script type="module"> on your page, with no CommonJS build. lit and @lit/context are the only runtime dependencies, and a test keeps that list from growing.

Install

Prereleases are on npm under the pre tag; there is no stable release yet.

pnpm add @checkly/elements@pre

Each prerelease is named after the commit it was built from, so pin the exact version in a project that has to reproduce its builds. To work on both sides at once, build this checkout (pnpm install also builds dist/) and pnpm link /absolute/path/to/checkly-elements from the consumer.

Consuming from another repository covers the other routes in.

Each element is imported from its own entry point, and importing it is what registers the tag:

<script type="module">
  import '@checkly/elements/status-dot'
</script>

<checkly-status-dot status="failing" label="Checkout API"></checkly-status-dot>
<checkly-status-dot status="success" size="small"></checkly-status-dot>

What is here

The catalog contains 15 display elements, plus optional API adapters, an HTTP client, and two public-resource sources. Display elements render from plain view-model properties, so a host can compose a board from its own store.

PathPurpose
src/coreThe base classes every element is built on: the token table, the four data states, the shadow/light-DOM machinery, the source channel.
src/clientThe HTTP transport, paging and visibility-aware polling used by source elements and server-side consumers.
src/adaptersPure mappings from dashboard and status-page wire responses onto the view-model the elements render.
src/sourcesOptional custom elements that fetch public dashboards or status pages and feed the rendering catalog beneath them.
src/elementsThe catalog. A file here is automatically an entry point, a size budget, and a subject of every conformance suite.
themes/checkly.css, generated: switches the elements' light and dark mode with a .dark class, as Checkly's applications do. The product look itself is the elements' default.
demo/A review hub for responsive states, themes, and live public-resource fetching.
scripts/The build's supporting cast: generated style docs, size budgets, the self-documenting check.

Fetching Checkly data

The rendering catalog and fetching client are separate entry points. A page that already owns its data therefore downloads no HTTP or polling code:

import { ChecklyClient } from '@checkly/elements/client'

const client = ChecklyClient.forDashboard({ dashboardId: 'my-dashboard' })
const statuses = await client.listCheckStatuses()

forDashboard and forStatusPage use the corresponding published-resource APIs. forApi is for server-side code and requires an account API key plus its account id.

Consumers that already perform their own requests can import the same mapping functions without taking the client or any elements:

import { adaptChecks } from '@checkly/elements/adapters'

For a framework-free public dashboard, import its source and wrap the elements that should receive its data:

<script type="module">
  import '@checkly/elements/dashboard-source'
  import '@checkly/elements/check-list'
</script>

<checkly-dashboard-source dashboard-id="my-dashboard">
  <checkly-check-list></checkly-check-list>
</checkly-dashboard-source>

Status pages use @checkly/elements/status-page-source and require version="v2" or version="v3". These source elements intentionally support public resources only; protected resources need the separately designed authentication bridge.

The status-page source feeds nested service uptime, incident banners/lists and maintenance lists. Select uptime with service-id, and use history on an incident list to show its archive. Your page owns the layout, service headings and branding; the source owns requests and the API-specific mapping.

Scoped account-data pilot

Author-composed pages can also use the experimental /v1/embed-tokens and /v1/elements-data endpoints, behind the ELEMENTS_EMBED account flag. A server-held API credential mints a short-lived JWT for explicit check IDs; the browser fetches once and passes the snapshot through adaptElementsSnapshot to the pure elements. No polling, dashboard or status-page dependency is needed.

The showcase repository holds a working example: a local server that keeps the key, the handshake, and the probes that prove it fails closed.

API keys are server side only

An account API key can read the account and does not belong in browser code. ChecklyClient.forApi() refuses cu_ and sv_ keys in a browser unless the caller explicitly sets unsafeAllowBrowserApiKey; that escape hatch still logs the risk. Prefer a published dashboard or status page, or proxy the specific account data through a backend that keeps the key private.

Develop

pnpm install         # also builds, via prepare
pnpm demo            # the demo pages on :5173
pnpm test            # build, unit specs, hygiene
pnpm test:browser    # real Chromium, via Playwright

The browser runner needs a binary the first time:

pnpm exec playwright install chromium

Every command, and what each one is for, is in docs/development.md.

Documentation

Using the elementsThe elements themselves: what they take, the four states every one of them has, and how a source feeds them.
RestylingMaking these look like your product: tokens, parts, slots, and dropping the shadow boundary. Includes the generated table of every token, part and slot the catalog declares.
Consuming from another repositoryThe three ways in — published to npm, pinned to a commit, or linked locally — and which to reach for.
DevelopmentCommands, the two test runners, the screenshot suite, the demo pages, entry points, size budgets.
PublishingHow a prerelease and a release run, what the registry's tags mean, and what has to be true before the first stable version.
AGENTS.mdInstructions for coding agents working in this repository.

License

MIT.

版本与发布记录

@checkly/elements 共发布 14 个版本,首次发布于 2026/10/09;过去 12 个月发布了 14 个版本。

版本发布日期距今
0.1.0-beta.2latest2026/10/1624 天前
0.1.0-beta.12026/10/1327 天前
0.1.0-pre-7938fecpre2026/10/1030 天前
0.1.0-pre-bb9db9a2026/10/0930 天前
0.1.0-pre-bb919d82026/10/0930 天前
0.1.0-pre-9ea350f2026/10/091 个月前

关于 @checkly/elements 的常见问题

@checkly/elements 是什么?

Embeddable Checkly monitoring UI as framework-agnostic custom elements

如何安装 @checkly/elements?

在项目目录运行 npm install @checkly/elements,或使用 pnpm add / yarn add / bun add。

@checkly/elements 支持 TypeScript 吗?

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

@checkly/elements 支持 ESM 还是 CommonJS?

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

@checkly/elements 需要什么版本的 Node.js?

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

@checkly/elements 可以商用吗?

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

@checkly/elements 的下载量有多少?

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

@checkly/elements 还在维护吗?

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