Embed Vault into your application using Vault JS

Create a better experience for your customers by adding our UI component that guides users through authorizing any integration that Apideck provides.

View on NPM
Client side
1import { ApideckVault } from '@apideck/vault-js'
2
3const MyComponent = () => {
4  const openVault = async () => {
5    // Create a Vault session
6    const response = await fetch('/api/vault/sessions', { method: 'POST' })
7    const { data } = await response.json()
8    const token = data.session_token
9
10    // Open Vault with a valid session token
11    ApideckVault.open({ token })
12  }
13
14  return (
15    <button onClick={openVault}>
16      Open Vault
17    </button>
18  )
19}
Server side
1import Apideck from '@apideck/node'
2
3export default async function handler(_, res) {
4  const apideck = new Apideck({
5    apiKey: '<api-key>',
6    appId: '<app-id>',
7    consumerId: '<consumer-id>'
8  })
9  const settings = {}
10  const result = await apideck.vault.sessionsCreate(settings)
11  res.json(result)
12}