@apideck/react-vault

中文文档
0.23.1发布于 2026/09/17MITTypeScriptESM + CJS近 30 天下载 1.5万

原始使用文档
文档目录3 节
  1. Usage
  2. Properties
  3. Deploy

Vault Core


🚨 We recommend using the new @apideck/vault-react or @apideck/vault-js packages.



A React component to embed Apideck Vault in any React application.

Go to the developer docs for a step-by-step guide.

React Vault | Vault JS | Vue Vault

Usage

Install the packages

npm install @apideck/react-vault

Create a Vault session inside your application to get a JSON Web Token. It's recommended to do this server-side, so you don't expose your API key.

With @apideck/node:

npm install @apideck/node
import { Apideck } from '@apideck/node';

const apideck = new Apideck({
  apiKey: 'REPLACE_WITH_API_KEY',
  appId: 'REPLACE_WITH_APP_ID',
  consumerId: 'REPLACE_WITH_CONSUMER_ID',
});

const { data } = await apideck.vault.sessionsCreate({});

console.log('Token:', data.session_token);

Pass the JSON Web Token to the Vault component:

import { Vault } from '@apideck/react-vault';

const MyComponent = () => {
  return (
    <Vault
      token="REPLACE_WITH_SESSION_TOKEN"
      trigger={<button>Open Vault</button>}
    />
  );
};

export default MyComponent;

If you are NOT using Tailwind CSS in your project, make your to include the styles in your project:

import '@apideck/react-vault/dist/styles.css';

If you are using Tailwind CSS you should include the package path in the content path of the tailwind.config.js.

// tailwind.config.js

module.exports = {
  content: ['./node_modules/@apideck/react-vault/**/*.js'],
  plugins: [require('@tailwindcss/forms')]
  ...
}

If you want to scope the connection results to a single Unified API, you can do that by giving the unifiedApi prop. If you want to open Vault for only a single connector, you should also provide the serviceId.

import { Vault } from '@apideck/react-vault';

const MyComponent = () => {
  return (
    <Vault
      token="REPLACE_WITH_SESSION_TOKEN"
      unifiedApi="accounting"
      serviceId="quickbooks"
      trigger={<button>Open Vault</button>}
    />
  );
};

export default MyComponent;

If you want to manually control the opening and closing of the modal, you can provide the open and onClose props.

import { Button } from '@apideck/components';
import { Vault } from '@apideck/react-vault';
import { useState } from 'react';

const VaultButton = ({ token }) => {
  const [openVault, setOpenVault] = useState(false);

  const toggleVault = () => {
    setOpenVault(!openVault);
  };

  return (
    <div className="flex items-center space-x-3">
      <Button text="Open Vault" onClick={toggleVault} />
      <Vault token={token} open={openVault} onClose={toggleVault} />
    </div>
  );
};

export default VaultButton;

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 { Vault } from '@apideck/react-vault';

const MyComponent = () => {
  return (
    <Vault
      token="REPLACE_WITH_SESSION_TOKEN"
      unifiedApi="accounting"
      serviceId="quickbooks"
      initialView="custom-mapping"
      trigger={<button>Open Vault</button>}
    />
  );
};

export default MyComponent;

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

Properties

PropertyTypeRequiredDefaultDescription
tokenstringtrue-The JSON Web Token returned from the Create Session call
triggerelementfalse-The component that should trigger the Vault modal on click
showAttributionbooleanfalsetrueShow "Powered by Apideck" in the backdrop of the modal backdrop
openbooleanfalsefalseSet the toggle to true to open the Vault modal, and set it to false to close the Vault modal
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 scope the connection results to that API. If also a serviceId is provided Vault opens for a single connection
serviceIdstringfalse-When unifiedApi and serviceId are provided Vault opens a single connection
showConsumerbooleanfalsefalseShow the consumer metadata provided when creating a session
initialViewConnectionViewTypefalse-Open Vault in a specific view for a connection session
localestringfalseenOpen Vault in a specific language
showLanguageSwitchbooleanfalsefalseShow language switch at bottom
showButtonLayoutbooleanfalsefalseShow button layout instead of dropdown menu in TopBar for connection actions
autoStartAuthorizationbooleanfalsefalseAutomatically start the authorization process. Applies Works only in the single connection mode

Deploy

User np to publish to NPM (2FA required). After publishing of new version make sure to upgrade @apideck/react-vault package inside the iframe-vault project and deploy it.

版本与发布记录

@apideck/react-vault 共发布 139 个版本,首次发布于 2022/02/17;过去 12 个月发布了 22 个版本。

版本发布日期距今
0.23.1latest2026/09/171 个月前
0.23.02026/07/303 个月前
0.22.02026/07/303 个月前
0.20.62026/07/024 个月前
0.20.52026/06/224 个月前
0.20.42026/06/104 个月前

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

如何安装 @apideck/react-vault?

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

@apideck/react-vault 支持 TypeScript 吗?

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

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

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

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

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

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

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

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

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

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

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