usePassage
Provides access to the Passage configuration, an instance of passage-js (opens in a new tab) and other Passage functionality.
import { usePassageJS } from '@passageidentity/passage-react';
import { Passage, Session, User } from '@passageidentity/passage-js';
const MyComponent = () => {
// if using PassageProvider
const { passageInstance, currentSession, currentUser, appId, lang, defaultCountryCode } = usePassageJS();
// if not using PassageProvider
const { passageInstance, currentSession, currentUser, appId, lang, defaultCountryCode } = usePassageJS({
appId: 'YOUR_PASSAGE_APP_ID',
lang: 'en',
defaultCountryCode: 'us',
});
// other code using data or methods provided by usePassage
};
Parameters
If using the PassageProvider to wrap your app, then you do not need to pass any parameters, unless you want to override a setting for this hook instance only.
Name | Required | Type | Description |
---|---|---|---|
props | No | UsePassageHookProps | Passage Configuration |
UsePassageHookProps
Name | Required | Type | Description |
---|---|---|---|
appId | No | string | Your Passage app id. |
defaultCountryCode | No | string | ISO Country code |
lang | No | string | Default language |
tokenStore | No | TokenStore | Custom token store instance |
Returns
Name | Type | Description |
---|---|---|
appId | string | Your Passage app id. |
defaultCountryCode | string | ISO Country code |
lang | string | Default language |
passageInstance | passage-js | Instance of Passage |
getCurrentSession | GetCurrentSessionFn | The current users Passage Session |
getCurrentUser | GetCurrentUserFn | The current user |
signOut | PassageSignOutFn | Method than can be called to sign out the current user |