Hooks
useSocialAccounts
Summary
A hook which can be used to trigger sign-in with social or social account linking and unlinking for an authenticated user. The hook needs to be initialized within a child of DynamicContextProvider.
Usage
The hook can receive an optional sessionTimeout
param that is used to cancel sign-in/linking due to inactivity. It’s value should be a number (time in milliseconds) and defaults to 10s (10000 ms).
Note: This is mainly used for X/Twitter oauth, since we cannot detect when the oauth window is closed for this provider.
Example setting timeout to 20s:
Available functions and states:
Method | Type | Description |
---|---|---|
error | SocialOAuthError | undefined | Contains the code and message in case of an error during the link or unlink process |
getLinkedAccountInformation | (provider: ProviderEnum) => SocialAccountInformation | Returns an object with the information about the linked account for the specified provider if there’s a linked account. If not, returns undefined. |
isLinked | (provider: ProviderEnum) => boolean | Returns true if user has an account linked for the specified provider. Otherwise returns false. |
isProcessing | boolean | Indicates whether a link or unlink request is in process |
linkSocialAccount | (provider: ProviderEnum) => Promise<void> | When called, will trigger the oauth linking for the specified provider |
signInWithSocialAccount | (provider: ProviderEnum) => Promise<void> | When called, will trigger the oauth sign-in for the specified provider |
unlinkSocialAccount | (provider: ProviderEnum) => Promise<void> | When called, it will unlink the user account for the specified provider |
Types
Linking/unlinking example
Sign-in example
Was this page helpful?