@behold/svelte

中文文档
0.1.7发布于 2025/09/25MITTypeScriptES Module零依赖近 30 天下载 3999

The official Behold Widget for Svelte

原始使用文档
文档目录8 节
  1. About
  2. Installation
  3. Usage
  4. 1. Import the component
  5. 2. Add to your app
  6. Load event
  7. A note about SSR
  8. Other framework components

The Official Behold Widget for Svelte

Behold Svelte

About

This package contains a Svelte version of the Behold embedded widget. It's a lightweight convenience wrapper around the core Behold widget web component, and allows easy integration into your Svelte projects.

Installation

Start by installing with your package manager of choice:

npm install @behold/svelte

// or
pnpm add @behold/svelte

// or
yarn add @behold/svelte

Usage

1. Import the component

import BeholdWidget from "@behold/svelte"

2. Add to your app

Use it like you would any other Svelte component:

<BeholdWidget feedId="YOUR_FEED_ID" />

The Behold widget component accepts a single property: feedId, which can be found by opening your feed in the Behold dashboard and clicking on "Embed Code".

All configuration and customization is handled in the Behold admin. When you make changes there it will automatically update your widget, no code modifications required. Because of browser caching, changes can take a minute or two to show up. Clearing your cache and incognito/private windows will help.

Behold feed settings page Behold feed embed code page

Load event

This component emits a load event after its initial render. It can be used as follows:

<BeholdWidget on:load={() => console.log("Loaded!")} feedId="YOUR_FEED_ID" />

A note about SSR

This component relies on client-only APIs and won't be pre-rendered by SSR or SSG. That means there will be a brief moment before it renders where its height will be 0px. You can prevent layout shifts this may cause by applying dimensions to a container element with CSS.

Other framework components

React Preact Vue.js Angular SolidJS

版本与发布记录

@behold/svelte 共发布 8 个版本,首次发布于 2024/02/24;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.1.7latest2025/09/251.1 年前
0.1.62025/07/281.3 年前
0.1.52024/02/272 年前
0.1.42024/02/262 年前
0.1.32024/02/262 年前
0.1.22024/02/252 年前

关于 @behold/svelte 的常见问题

@behold/svelte 是什么?

The official Behold Widget for Svelte

如何安装 @behold/svelte?

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

@behold/svelte 支持 TypeScript 吗?

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

@behold/svelte 支持 ESM 还是 CommonJS?

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

@behold/svelte 可以商用吗?

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

@behold/svelte 的下载量有多少?

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

@behold/svelte 还在维护吗?

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