@truv/react
TypeScript icon, indicating that this package has built-in type declarations

2.2.0 • Public • Published

Truv React Bridge npm version

React library for integrating with the Truv Bridge

Install

With npm:

npm install @truv/react --save

With yarn

yarn add -S @truv/react

Usage

Modal

import { useState } from 'react';
import TruvBridge from '@truv/react';

const ModalBridge = () => {
  const [isOpened, setOpened] = useState(false);

  return (
    <>
      <button onClick={() => setOpened(true)}>Open</button>
      <TruvBridge
        bridgeToken="<previously generated bridge token>" // more info https://docs.truv.com/reference/bridge-tokens_create
        onClose={() => setOpened(false)}
        onSuccess={(publicToken, metaData) => {
          console.log(publicToken, metaData);
        }}
        isOpened={isOpened}
      />
    </>
  );
}

Inline

import { useState } from 'react';
import { TruvBridgeInline } from '@truv/react';

const InlineBridge = () => {
  const [isOpened, setOpened] = useState(false);

  return (
    <>
      <button onClick={() => setOpened(true)}>Open</button>
      <TruvBridgeInline
        // We can pass the properties of the div element here
        style={{ width: '300px', height: '500px', backgroundColor: 'red' }}
        // Required parameters for opening the bridge
        isOpened={isOpened}
        bridgeParams={{
          bridgeToken: "<previously generated bridge token>", // more info https://docs.truv.com/reference/bridge-tokens_create
          onClose: () => setOpened(false),
          onSuccess: () => {
            console.log('Success');
          }
        }}
      />
    </>
  );
}

Readme

Keywords

Package Sidebar

Install

npm i @truv/react

Weekly Downloads

1,410

Version

2.2.0

License

ISC

Unpacked Size

6.73 kB

Total Files

4

Last publish

Collaborators

  • sergnek
  • vesai_citadelid
  • dmitrydorofeev-citadel