@beefree.io/sdk

中文文档
11.8.0发布于 2026/11/05Apache-2.0TypeScriptESM + CJS近 30 天下载 49.9万

wrapper of BeefreeSDK

原始使用文档
文档目录34 节
  1. Why Beefree SDK?
  2. How to use it
  3. Demo
  4. Do you want to try out an integration locally?
  5. How to use this module for your own
  6. install
  7. Initialize the builder
  8. Get token(clientId, clientSecret)
  9. Important Security Notice
  10. new Bee(token, authConf?)
  11. Configuring the editor (beeConfig)
  12. Template JSON
  13. After you have started the builder it's possible to trigger…
  14. Methods
  15. start(beeConfig, template, endpoint, options)
  16. load(template)
  17. reload(template)
  18. save()
  19. saveAsTemplate()
  20. send()
  21. preview()
  22. toggleStructure()
  23. toggleComments()
  24. togglePreview()
  25. showComment(uuid)
  26. loadConfig(ClientConfig)
  27. join(beeConfig, sessionId)
  28. loadWorkspace(type)
  29. loadStageMode(arg)
  30. loadConfig(ClientConfig)
  31. updateToken(updateTokenArgs)
  32. getConfig()
  33. translateTemplate(arg)
  34. resetTemplateTranslation(arg)

Beefree SDK logo

Official Beefree SDK wrapper

CI PRs Welcome License NPM

A simple module to use the Beefree SDK

Why Beefree SDK?

Choose a reliable, easy-to-integrate multi-content type digital platform you can build on. Beefree SDK is more than an embeddable visual builder with a great drag-and-drop user experience. It’s a reliable, highly customizable email, landing page & popup builder.

Go from proof-of-concept to production in days, not months. Beefree SDK can be highly customized in how it looks, what it does, and how it interacts with your application. Deliver your business exactly what it needs with a small development effort.

You can embed it into your application!

Visit our developer documentation [https://docs.beefree.io/]

How to use it

Demo

It's free to use on 'https://beefree.io': you don't even need to create an account of any kind.

Do you want to try out an integration locally?

This project comes with an example integration to run the SDK builder locally. It uses the SDK sources from the /src folder.

  1. Install Nodejs (also npm, which should come with nodejs already) or Yarn.
  2. clone this repository:
    • git clone https://github.com/BeefreeSDK/beefree-sdk-npm-official.git
  3. npm install or yarn install (if you have it installed) in the folder cloned
  4. rename the local .env.sample file to .env
  5. run npm start or yarn start
  6. Open http://localhost:8081 in your favourite browser.
  7. Have fun!

This demo integration is primarily meant for development purpose on the sources if the Beefree SDK NPM package.

How to use this module for your own

install

You can either install it with npm or yarn.

npm install --save @beefree.io/sdk

or

yarn add @beefree.io/sdk

Initialize the builder

Get token(clientId, clientSecret)

You need to be authorized to start using the editor: Beefree help documentation portal has a nice post explaining how to do it

Important Security Notice

As of v9.0.0, the getToken method has been renamed to UNSAFE_getToken. This change makes it clear that this method is intended only for quick start tutorials, POCs, and local testing. To protect your secret key, we strongly recommend implementing getToken on the server-side in all production environments.

Pass your credential on UNSAFE_getToken method and start the SDK in the returning promise. Example below:

import BeefreeSDK from '@beefree.io/sdk'

// Put your credentials in the .env file
const clientId = process.env.CLIENT_ID
const clientSecret = process.env.CLIENT_SECRET
const beeConfig = {...}

const template = {...}
const beeTest = new BeefreeSDK(token, authConfiguration)

beeTest.UNSAFE_getToken(clientId, clientSecret)
  .then(() => beeTest.start(beeConfig, template))

new Bee(token, authConf?)

Initialize the BEE instance with a server side generated token


import BeefreeSDK from '@beefree.io/sdk'

const authConf = {...}
const beeConfig = {...}
const template = {...}

// You can add your personal configuration, if you omit some properties, the builder will use its default configuration
const authConf = {
  authUrl: process.env.YOUR_AUTH_URL,
  beePluginUrl: process.env.YOUR_HOST_URL
}
const builder = new BeefreeSDK(token, authConf)
builder.start(beeConfig, template)

Configuring the editor (beeConfig)

It requires a configuration for using the editor, beefree help documentation portal has a nice post explaining how to do it

Here is an example of the configuration; just read the official documentation for an extended version.

const beeConfig = {
  container: 'beefree-sdk-container', // Identifies the id of div element that contains the Beefree SDK builder
  language: 'en-US',
  onSave: (jsonFile, htmlFile) => {
    console.log('onSave', jsonFile, htmlFile)
  },
  onSaveAsTemplate: (jsonFile) => {
    console.log('onSaveAsTemplate', jsonFile)
  },
  onSend: (htmlFile) => {
    console.log('onSend', htmlFile)
  },
  onError: (errorMessage) => {
    console.log('onError ', errorMessage)
  }
}

Alternative use of container as HTML Element:

const containerElement = document.getElementById('beefree-sdk-container')

const beeConfig = {
  container: containerElement,
  ...
}

Template JSON

It requires an initial template to start editing. Learn more here

Some json avaible here https://github.com/BeefreeSDK/beefree-sdk-assets-templates

After you have started the builder it's possible to trigger this method

Methods

start(beeConfig, template, endpoint, options)

After the initialization you can call start to load the builder on the page; the method needs two parameters:

  • BEE configuration (required - js object)
  • Template (required - JSON)
  • Endpoint (optional - string or null)
  • Options (optional - js object e.g. { shared: true })

this returns a promise that is resolved after we call the builder's start function

load(template)

This changes the template; call load with the new template

reload(template)

This changes the template by trigging the loading dialog; just call reload with the new template

save()

This calls the Beefree SDK save method, which in turn will trigger the callback onSave defined on the configuration for getting fresh HTML of the email and the JSON template updated.

saveAsTemplate()

This calls the Beefree SDK saveAsTemplate method, which in turn will trigger the callback onSaveAsTemplate defined in the configuration for getting only the current JSON of the instance.

send()

This calls the Beefree SDK send method, which in turn will trigger the callback send defined in the configuration for getting only the current html of the instance.

preview()

This calls the Beefree SDK preview method, which triggers the preview modal inside the editor.

toggleStructure()

This calls the Beefree SDK toggleStructure method, which toggles the structure helper on the editor's stage.

toggleComments()

This calls the Beefree SDK toggleStructure method, which toggles the comments section on the editor's sidebar.

togglePreview()

This calls the Beefree SDK togglePreview method, which opens/closes the message preview behavior within the editor.

showComment(uuid)

This calls the Beefree SDK showComment method, which opens a specific comment and scrolls the stage to the related element. The method needs one parameter, a comment 'uuid' as a string.

loadConfig(ClientConfig)

This calls the Beefree SDK loadConfig method, which reloads the JSON configuration used to initialize the builder.

join(beeConfig, sessionId)

After the initialization you can call join to load the builder on the page and join a collaborative editing session; the method needs two parameters:

  • BEE configuration (JS object)
  • SessionID (string obtained from onSessionStarted callback)

this returns a promise that has resolved after we call the builder's start function. Visit the docs for more details about co-editing.

loadWorkspace(type)

This call the Beefree SDK loadWorkspace method, which accepts one of the following parameters: 'default'|'mixed'|'amp_only'|'html_only'. Visit the docs for more details about workspaces.

loadStageMode(arg)

This call the Beefree SDK loadStageMode method, which accepts an object parameter with the following structure: { mode: 'desktop'|'mobile', display: 'blur'|'hide'}. Visit the docs for more details about design mode.

loadConfig(ClientConfig)

This calls the Beefree SDK loadConfig method, which reloads the JSON configuration used to initialize the builder.

updateToken(updateTokenArgs)

This calls the Beefree SDK updateToken method, and permits the refresh of the access token.

getConfig()

This calls the Beefree SDK getConfig method and returns the clientConfig used by the SDK.

translateTemplate(arg)

This calls the Beefree SDK translateTemplate method, which accepts an object containing the language and returns a Promise. Visit the docs for more details about auto translation.

resetTemplateTranslation(arg)

This calls the Beefree SDK resetTemplateTranslation method, which accepts an object containing the language and returns a Promise. Visit the docs for more details about auto translation.

版本与发布记录

@beefree.io/sdk 共发布 197 个版本,首次发布于 2023/10/31;过去 12 个月发布了 40 个版本。

版本发布日期距今
11.8.0latest2026/11/052 天前
11.7.22026/10/2018 天前
11.7.2-BEEPRO-9678.02026/10/1325 天前
11.7.12026/10/0830 天前
11.7.1-fix-BEE-12535-tinymce-contentdialog-types.0unstable2026/09/291 个月前
11.7.02026/09/171 个月前

其他发布通道:feature-BEE-10731-fe-api-sidebar-tab → 9.2.0-feature-BEE-10731-fe-api-sidebar-tab.0,fix-BEE-10878-types → 9.4.1-fix-BEE-10878-types.4,unstable → 11.7.1-fix-BEE-12535-tinymce-contentdialog-types.0。

关于 @beefree.io/sdk 的常见问题

@beefree.io/sdk 是什么?

wrapper of BeefreeSDK

如何安装 @beefree.io/sdk?

在项目目录运行 npm install @beefree.io/sdk,或使用 pnpm add / yarn add / bun add。

@beefree.io/sdk 支持 TypeScript 吗?

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

@beefree.io/sdk 支持 ESM 还是 CommonJS?

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

@beefree.io/sdk 可以商用吗?

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

@beefree.io/sdk 的下载量有多少?

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

@beefree.io/sdk 还在维护吗?

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