npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@apideck/react-vault

v0.12.10

Published

<br />

Downloads

16,407

Readme

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

| Property | Type | Required | Default | Description | | ------------------ | -------------------------------- | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | | token | string | true | - | The JSON Web Token returned from the Create Session call | | trigger | element | false | - | The component that should trigger the Vault modal on click | | showAttribution | boolean | false | true | Show "Powered by Apideck" in the backdrop of the modal backdrop | | open | boolean | false | false | Set the toggle to true to open the Vault modal, and set it to false to close the Vault modal | | onClose | () => void | false | - | Function that gets called when the modal is closed | | onConnectionChange | (connection: Connection) => void | false | - | 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) => void | false | - | Function that gets called when the user deletes a connection | | unifiedApi | string | false | - | 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 | | serviceId | string | false | - | When unifiedApi and serviceId are provided Vault opens a single connection | | showConsumer | boolean | false | false | Show the consumer metadata provided when creating a session | | initialView | ConnectionViewType | false | - | Open Vault in a specific view for a connection session | | locale | string | false | en | Open Vault in a specific language | | showLanguageSwitch | boolean | false | false | Show language switch at bottom |