@tryvital/vital-link
v0.1.7
Published
React hooks and components for integrating with the Vital Link.
Downloads
99,281
Readme
React Vital Link
React hooks and components for integrating with the Vital Link.
Install
With npm:
npm i @tryvital/vital-linkWith yarn
yarn add @tryvital/vital-linkDocumentation
The official Vital Link docs provide a full reference on using this library.
Examples
Using React hooks
import React, { useCallback } from 'react';
import { useVitalLink } from '@tryvital/vital-link';
const App = () => {
const onSuccess = useCallback((metadata) => {
// send token to server
}, []);
const config = { onSuccess }
const { open, ready, error, env: "sandbox" } = useVitalLink(config);
const handleVitalOpen = async () => {
setLoading(true);
const GENERATED_LINK_TOKEN = await getTokenFromBackend(userKey);
open(GENERATED_LINK_TOKEN);
setLoading(false);
};
return (
<button
type="button"
className="button"
onClick={handleVitalOpen}
disabled={isLoading || !ready}
>
Open Vital Link
</button>
);
};
export default App;