Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@stackone/react-hub

Package Overview
Dependencies
Maintainers
3
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stackone/react-hub

Allow your users to quickly integrate with several services with StackOne. The `@stackone/react-hub` introduces an easy-to-use React hook for integrating with your web app.

Source
npmnpm
Version
1.0.8
Version published
Weekly downloads
26K
-22.95%
Maintainers
3
Weekly downloads
 
Created
Source

StackOne Hub For React

Allow your users to quickly integrate with several services with StackOne. The @stackone/react-hub introduces an easy-to-use React hook for integrating with your web app.

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.

FAQs

Package last updated on 02 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts