@apideck/vault-js

中文文档
1.8.1发布于 2026/05/13MITTypeScriptESM + CJS零依赖近 30 天下载 20.5万
原始使用文档
文档目录6 节
  1. Installation
  2. Package
  3. Script
  4. Prerequisites
  5. Usage
  6. Properties

Total Downloads Latest Stable Version

Vault JS

A vanilla JavaScript library to embed Apideck Vault in any web application.

Vault JS | React Vault | Vue Vault

Installation

Package

npm install @apideck/vault-js

Script

If you don't want to set up a build environment, you can get @apideck/vault-js from a CDN like unpkg.com and it will be globally available through the window.ApideckVault object.

<script src="https://unpkg.com/@apideck/vault-js"></script>

Prerequisites

Before opening the Vault modal with @apideck/vault-js, you need to create a Vault session from your backend using the Vault API or one of our SDKs. Find out more in the docs.

Usage

Pass the JWT you got from the Vault session to @apideck/vault-js:

import { ApideckVault } from '@apideck/vault-js';

ApideckVault.open({
  token: 'REPLACE_WITH_SESSION_TOKEN',
});

If you want to only show integrations for a single Unified API, you can do that by passing the unifiedApi option. If you want to open Vault for only a single integration, you can provide the serviceId option.

import { ApideckVault } from '@apideck/vault-js';

ApideckVault.open({
  token: 'REPLACE_WITH_SESSION_TOKEN',
  unifiedApi: 'accounting',
  serviceId: 'quickbooks',
});

If you want to get notified when the modal opens and closes, you can provide the onReady and onClose options.

import { ApideckVault } from '@apideck/vault-js';

ApideckVault.open({
  token: 'REPLACE_WITH_SESSION_TOKEN',
  onClose: () => {
    console.log('closed!');
  },
  onReady: () => {
    console.log('ready!');
  },
});

If you want to open a specific view you can pass the initialView prop. The available views are settings, configurable-resources, and custom-mapping.

import { ApideckVault } from '@apideck/vault-js';

ApideckVault.open({
  token: 'REPLACE_WITH_SESSION_TOKEN',
  unifiedApi: 'accounting',
  serviceId: 'quickbooks',
  initialView: 'custom-mapping',
});

If you want to open vault in a specific language you can pass a locale. The available locales are en (default), nl, de, fr, and es.

import { ApideckVault } from '@apideck/vault-js';

ApideckVault.open({
  token: 'REPLACE_WITH_SESSION_TOKEN',
  locale: 'nl',
});

You can also show a language switch at the bottom of the modal by setting the showLanguageSwitch property.

import { ApideckVault } from '@apideck/vault-js';

ApideckVault.open({
  token: 'REPLACE_WITH_SESSION_TOKEN',
  showLanguageSwitch: true,
});

If you want to use the button layout instead of the dropdown menu in the TopBar for connection actions, you can set the showButtonLayout property.

import { ApideckVault } from '@apideck/vault-js';

ApideckVault.open({
  token: 'REPLACE_WITH_SESSION_TOKEN',
  showButtonLayout: true,
});

You can also close the modal programmatically by calling ApideckVault.close().

If you want to show a logo on top of the modal, you can set the logo property on the theme object you can provide through the session. View Vault API documentation.

Properties

PropertyTypeRequiredDefaultDescription
tokenstringtrue-The JSON Web Token returned from the Create Session API
showAttributionbooleanfalsetrueShow "Powered by Apideck" in the backdrop of the modal backdrop
open() => voidfalse-Function to open the Vault modal
close() => voidfalse-Function to close the Vault modal
onReady() => voidfalse-Function that gets called when the modal is opened
onClose() => voidfalse-Function that gets called when the modal is closed
onConnectionChange(connection: Connection) => voidfalse-Function that gets called when the user updates a connection. This can be linking their account, filling out settings or adding a new connection
onConnectionDelete(connection: Connection) => voidfalse-Function that gets called when the user deletes a connection
unifiedApistringfalse-When unifiedApi is provided it will only show integrations from that API.
serviceIdstringfalse-When unifiedApi and serviceId are provided Vault opens a single integration
showConsumerbooleanfalsefalseIf true it shows the current consumer metadata at the bottom of the modal
initialViewConnectionViewTypefalse-Open Vault in a specific view for a connection: "settings", "configurable-resources", or "custom-mapping"
localestringfalse"en"Open Vault in a specific language: "en", "nl", "de", "fr" or "es"
showLanguageSwitchbooleanfalsefalseShow language switch at bottom
showButtonLayoutbooleanfalsefalseUse button layout instead of dropdown menu in TopBar for connection actions
autoStartAuthorizationbooleanfalsefalseIf true it will automatically start the authorization process for the connection.

版本与发布记录

@apideck/vault-js 共发布 23 个版本,首次发布于 2022/12/15;过去 12 个月发布了 1 个版本。

版本发布日期距今
1.8.1latest2026/05/135 个月前
1.8.02025/07/021.3 年前
1.7.02025/05/291.4 年前
1.6.02024/01/312 年前
1.5.22024/01/312 年前
1.5.12024/01/252 年前

关于 @apideck/vault-js 的常见问题

如何安装 @apideck/vault-js?

在项目目录运行 npm install @apideck/vault-js,或使用 pnpm add / yarn add / bun add。

@apideck/vault-js 支持 TypeScript 吗?

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

@apideck/vault-js 支持 ESM 还是 CommonJS?

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

@apideck/vault-js 需要什么版本的 Node.js?

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

@apideck/vault-js 可以商用吗?

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

@apideck/vault-js 的下载量有多少?

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

@apideck/vault-js 还在维护吗?

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