0.12.9 • Published 2 days ago

@apideck/react-vault v0.12.9

Weekly downloads
-
License
MIT
Repository
-
Last release
2 days ago

Vault Core

🚨 We recommend using the new @apideck/vault-react package.


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
0.12.9

2 days ago

0.12.7

28 days ago

0.12.8

28 days ago

0.12.6

28 days ago

0.12.5

3 months ago

0.12.4

3 months ago

0.12.2

3 months ago

0.12.3

3 months ago

0.12.1

3 months ago

0.12.0

3 months ago

0.11.3

5 months ago

0.11.0

6 months ago

0.11.1

6 months ago

0.11.2

6 months ago

0.10.4

6 months ago

0.10.5

6 months ago

0.9.0

7 months ago

0.9.2

7 months ago

0.9.1

7 months ago

0.10.1

6 months ago

0.10.2

6 months ago

0.10.3

6 months ago

0.10.0

6 months ago

0.7.2

9 months ago

0.7.1

9 months ago

0.7.0

9 months ago

0.8.0

9 months ago

0.6.1

10 months ago

0.5.0

11 months ago

0.4.10

11 months ago

0.6.0

11 months ago

0.4.9

12 months ago

0.4.8

12 months ago

0.3.7

1 year ago

0.4.5

12 months ago

0.4.4

1 year ago

0.4.7

12 months ago

0.4.6

12 months ago

0.4.1

1 year ago

0.4.0

1 year ago

0.4.3

1 year ago

0.4.2

1 year ago

0.3.0

1 year ago

0.3.6

1 year ago

0.3.5

1 year ago

0.3.2

1 year ago

0.3.1

1 year ago

0.3.4

1 year ago

0.3.3

1 year ago

0.2.35

1 year ago

0.2.34

1 year ago

0.2.33

1 year ago

0.2.32

1 year ago

0.2.27

1 year ago

0.2.26

1 year ago

0.2.25

1 year ago

0.2.24

1 year ago

0.2.23

1 year ago

0.2.22

1 year ago

0.2.30

1 year ago

0.2.31

1 year ago

0.2.29

1 year ago

0.2.28

1 year ago

0.2.21

1 year ago

0.2.20

1 year ago

0.2.19

1 year ago

0.2.18

1 year ago

0.2.17

1 year ago

0.2.16

1 year ago

0.2.15

1 year ago

0.2.14

2 years ago

0.2.13

2 years ago

0.2.12

2 years ago

0.2.11

2 years ago

0.2.10

2 years ago

0.2.7

2 years ago

0.2.6

2 years ago

0.2.9

2 years ago

0.2.8

2 years ago

0.2.5

2 years ago

0.2.3

2 years ago

0.2.4

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.10

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago