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.

NameRequiredTypeDescription
propsNoUsePassageHookPropsPassage Configuration

UsePassageHookProps

NameRequiredTypeDescription
appIdNostringYour Passage app id.
defaultCountryCodeNostringISO Country code
langNostringDefault language
tokenStoreNoTokenStoreCustom token store instance

Returns

NameTypeDescription
appIdstringYour Passage app id.
defaultCountryCodestringISO Country code
langstringDefault language
passageInstancepassage-jsInstance of Passage
getCurrentSessionGetCurrentSessionFnThe current users Passage Session
getCurrentUserGetCurrentUserFnThe current user
signOutPassageSignOutFnMethod than can be called to sign out the current user