1.0.12 • Published 2 months ago

@stackone/react-hub v1.0.12

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

StackOne Hub For React

Allow your users to quickly integrate with several services via StackOne. The @stackone/react-hub introduces an easy-to-use React hook to be able to embed the StackOne integrations hub into your SaaS application.

Install

# NPM
npm install --save @stackone/react-hub

# Yarn
yarn add @stackone/react-hub

Usage

Use React hook to start the Connect flow. Listen to the callbacks to know when an account has been linked or whether the flow has been cancelled. The callback will give you the information about the account added/updated - you may also retrieve this information by using webhooks or the API.

import { useStackOneHub } from '@stackone/react-hub';

const LinkAccountButton = () => {
  const { startConnect } = useStackOneHub();

  const startFlow = useCallback(async () => {
    const sessionToken = await retrieveConnectSessionToken();
    startConnect({ sessionToken });
  }, [startConnect]);

  return (
    <button onClick={startFlow}>Connect Account</button>
  );
};

Connect Options

When starting the flow, you may pass a few options:

const { startConnect } = useStackOneHub();

startConnect(options)
NameTypeRequiredDescription
sessionTokenstringYesConnect session token created in the backend. The session token allows users to manage their accounts in the frontend. You may limit a connect session token to selected categories or to a given service
apiUrlstringNoWhich API instance should it connect to. It will automatically infer it from your connect session.
onSuccess(account)functionNoCalled when an account is successfully linked. The account param gives you information about the linked account.
onCancel()functionNoCalled when the connect flow is closed without an account being linked.
onClose()functionNoCalled every time the connect flow is closed regardless of whether an account has been linked or not.

Contribute & Release

This repose uses conventional commit. The repo use semantic-release and the package version is automatically determined based on the commit messages.

Release

Use the Manual release workflow to trigger a release. The package version and changelog will automatically be generated based on conventional commits.

1.0.12

2 months ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.0

1 year ago