Main hook for managing YouVersion authentication state. Provides access to authentication status, user information, and sign-in/sign-out functionality.
Scopes: To access userInfo.name and userInfo.email, you must request the profile and email scopes when signing in. Without these scopes, those fields will be undefined.
Return Types:
Code
type UseYVAuthReturn = { /** Current authentication state (isAuthenticated, isLoading, tokens, error) */ auth: AuthenticationState; /** User profile extracted from JWT tokens, or null if not authenticated */ userInfo: YouVersionUserInfo | null; /** Sign out the current user */ signOut: () => void; /** Programmatically trigger sign-in. Not needed if using YouVersionAuthButton. */ signIn: (params?: { redirectUrl?: string; scopes?: AuthenticationScopes[]; }) => Promise<void>; /** Process the OAuth callback. YouVersionProvider handles this automatically — only needed for custom callback page implementations. */ processCallback: () => Promise<SignInWithYouVersionResult | null>; /** The authRedirectUrl configured on YouVersionProvider. Read-back convenience — rarely needed directly. */ redirectUri?: string;};interface AuthenticationState { isAuthenticated: boolean; isLoading: boolean; accessToken: string | null; idToken: string | null; result: SignInWithYouVersionResult | null; error: Error | null;}type SignInWithYouVersionResultProps = { accessToken?: string; expiresIn?: number; refreshToken?: string; idToken?: string; yvpUserId?: string; name?: string; profilePicture?: string; email?: string;};declare class SignInWithYouVersionResult { readonly accessToken: string | undefined; readonly expiryDate: Date | undefined; readonly refreshToken: string | undefined; readonly idToken: string | undefined; readonly yvpUserId: string | undefined; readonly name: string | undefined; readonly profilePicture: string | undefined; readonly email: string | undefined; constructor({ accessToken, expiresIn, refreshToken, idToken, yvpUserId, name, profilePicture, email, }: SignInWithYouVersionResultProps);}interface YouVersionUserInfoJSON { name?: string; id?: string; avatar_url?: string; email?: string;}declare class YouVersionUserInfo { readonly name?: string; readonly userId?: string; readonly email?: string; readonly avatarUrlFormat?: string; constructor(data: YouVersionUserInfoJSON); getAvatarUrl(width?: number, height?: number): URL | null; get avatarUrl(): URL | null;}
JWT Token Management: User information is extracted directly from JWT tokens, eliminating the need for separate API calls. The authentication uses PKCE (Proof Key for Code Exchange) OAuth flow for enhanced security.
Bible Content Hooks
useBibleClient
Returns a configured BibleClient instance for direct API calls.
useBibleSearch manages trending queries, debounced suggestions, verse results, pagination, and retries. useSearchClient returns the core search client for direct requests. See the search guide for a custom interface and the hook's search phases.
useUnifiedSearch
Retrieve top results across content kinds, such as verse references and related topics, in one request inside YouVersionProvider. Unlike useBibleSearch, this hook has no suggestions, input debounce, or pagination. See the unified search example.
Arguments:useUnifiedSearch(props, apiOptions?)
props (UseUnifiedSearchProps): Required query, versionId, and languageRanges; optional userIntent and fields. These have the same meanings as the core searchUnified parameters.
apiOptions (UseApiDataOptions, optional):
enabled (boolean, default true): Set to false until the query is ready. While disabled, data and error are null, and loading is false.
keepPreviousData (boolean, default true): Keep the previous result while changed inputs load. Set to false to clear it instead.
Return value:UseUnifiedSearchResult
data: SearchUnifiedResponse or null. Contains verses, topics, images, didYouMean, searchInsteadFor, and optional userIntent. Image hits have { id: string; passageId: string }; image selection requires backend support. Verse hits contain passage IDs, not text.
loading: Whether the current inputs are waiting for their results. A background refresh of settled data does not set this to true.
error: Error or null.
refetch(): Request fresh results for the current enabled query, such as after an error.
Changes to the query, Bible version, language preferences, intent, or result kinds select a new result set. Your interface controls when to apply those inputs.