@clerk/chrome-extension

中文文档
3.1.107发布于 2026/11/14MITTypeScriptESM + CJS构建来源已验证近 30 天下载 39.2万

Clerk SDK for Chrome extensions

原始使用文档
文档目录10 节
  1. Getting Started
  2. Prerequisites
  3. Feature Support
  4. Usage
  5. Example repositories
  6. Support
  7. Community
  8. Contributing
  9. Security
  10. License


@clerk/chrome-extension

Getting Started

Clerk is the easiest way to add authentication and user management to your Browser Extension. Add sign up, sign in, and profile management to your application in minutes.

Prerequisites

Feature Support

Please see the latest extension authentication support matrix in the Clerk documentation for more information.

Usage

  1. Installation: npm install @clerk/chrome-extension

  2. Set a consistent extension key: A browser extension can be identified by its unique key, in a similar way to how a website can be identified by its domain. You will need to explicitly configure your extension's key or it will change often. If the key changes, it can cause the extension to fail. See the Configure a Consistent Key guide for more information.

  3. Update Clerk Settings: Once you've set up a consistent extension key, you'll need to configure your Clerk settings to allow the extension to communicate with your Clerk API. You can do this by adding the extension key to the list of allowed origins in your Clerk settings. Setting the allowed_origins is required for both Development and Production instances.

    curl  -X PATCH https://api.clerk.com/v1/instance \
          -H "Content-type: application/json" \
          -H "Authorization: Bearer <CLERK_SECRET_KEY>" \
          -d '{"allowed_origins": ["chrome-extension://<YOUR_EXTENSION_KEY>"]}'
    
  4. Set Environment Variables: Retrieve the Publishable key from your Clerk dashboard and set it as an environment variable.

    # Vite
    VITE_CLERK_PUBLISHABLE_KEY=pk_test_xxx
    
    # Plasmo
    PLASMO_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_xxx
    
  5. Update the extension manifest: You'll need to update your extension manifest permissions to support Clerk.

    1. Base configuration: Use this if you plan to only use Clerk in the context of the extension.
    2. Session sync configuration: Use this if you plan to share authentication with a website in the same browser.
  6. Add Clerk to your app: Though not required, we generally suggest using Plasmo for browser extension development. This will enforce common standards across your extension as well as allow for easier integration with other browsers in the future.

    1. Via ClerkProvider: This is the general approach to all extensions. From here you'll be able to support extension-only authentication as well as sharing authentication with a website in the same browser.
    2. Via service workers: If you also require the use of background service workers, this will allow you to access the Clerk client from the extension context.

Example repositories

Support

For help, visit our support page.

Community

Join our Discord community to connect with other developers.

Contributing

We're open to all community contributions! If you'd like to contribute in any way, please read our contribution guidelines and code of conduct.

Security

@clerk/chrome-extension follows good practices of security, but 100% security cannot be assured.

@clerk/chrome-extension is provided "as is" without any warranty. Use at your own risk.

For more information and to report security issues, please refer to our security documentation.

License

This project is licensed under the MIT license.

See LICENSE for more information.

版本与发布记录

@clerk/chrome-extension 共发布 6,988 个版本,首次发布于 2023/03/31;过去 12 个月发布了 2560 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
3.1.107latest2026/11/14今天
3.1.108-canary.v202611140009492026/11/14今天
3.1.107-canary.v202611132355002026/11/14今天
3.1.107-canary.v202611132203122026/11/14今天
3.1.107-canary.v202611131952462026/11/14今天
3.1.107-canary.v202611131936102026/11/14今天

其他发布通道:staging → 0.5.0-staging.v4f9214a,alpha-v5 → 1.0.0-alpha-v5.18,beta-v5 → 1.0.0-beta-v5.21,beta → 1.0.0-beta.49,latest-v4 → 0.7.14,canary-core3 → 3.0.0-canary-core3.v20251208193449。

关于 @clerk/chrome-extension 的常见问题

@clerk/chrome-extension 是什么?

Clerk SDK for Chrome extensions

如何安装 @clerk/chrome-extension?

在项目目录运行 npm install @clerk/chrome-extension,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^18.0.0 || ~19.0.3 || ~19.1.4 || ~19.2.3 || ~19.3.0-0)、react-dom(^18.0.0 || ~19.0.3 || ~19.1.4 || ~19.2.3 || ~19.3.0-0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@clerk/chrome-extension 支持 TypeScript 吗?

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

@clerk/chrome-extension 支持 ESM 还是 CommonJS?

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

@clerk/chrome-extension 需要什么版本的 Node.js?

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

@clerk/chrome-extension 可以商用吗?

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

@clerk/chrome-extension 的下载量有多少?

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

@clerk/chrome-extension 还在维护吗?

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