Authentication is optional. When enabled, the SDK signs users in with YouVersion using the PKCE OAuth flow, stores tokens securely in expo-secure-store, caches the user's profile, and refreshes tokens automatically.
The YouVersionProvider, YouVersionAuthButton, and the useYVAuth hook power the flow:
YouVersionProvider— pass anauthconfig to enable authentication.YouVersionAuthButton— pre-styled sign-in/sign-out button from@youversion/platform-react-native-expo-ui.useYVAuth— imported from@youversion/platform-react-native-expo-coreto read auth state and trigger sign-in/sign-out when you build a custom UI.
Use YouVersionAuthButton for a drop-in button, or useYVAuth when you need full control over the sign-in experience.
Setup
-
Add a URL scheme to your app
The OAuth redirect comes back to your app via a deep link. Register a custom URL scheme in
app.json— this becomes the prefix for your redirect URI (e.g. schemecom.example.myapp→ redirectcom.example.myapp://callback).Pick a unique value, typically a reverse-DNS identifier for your app. It must contain only lowercase letters, numbers, dots, and hyphens. Custom URL schemes have no ownership registry on either platform: on Android, if two installed apps claim the same scheme the OS shows a disambiguation dialog asking the user which app to open, and on iOS there is no defined process for which app wins a duplicated scheme — so choose a scheme unique to your app:
app.json -
Register your redirect URI
Your redirect URI is the value from step 1 — your scheme plus
://callback(e.g.com.example.myapp://callback). Add it as a Callback URI in your app's settings in the YouVersion Platform console.In code,
expo-linkingbuilds the same URI for you — install it withnpx expo install expo-linking:CodeThe
redirectUriyou pass to the provider must match a Callback URI registered in your YouVersion Platform app settings, or sign-in will fail. -
Enable auth on the provider
Pass the
authconfig toYouVersionProvider:app/_layout.tsxScopes: request
"profile"and"email"to read the user's name, email, and avatar. Without them, those fields onuserInfowill beundefined. Scopes default to["profile", "email"]. -
Add the callback route
Create a route that matches the path in your
redirectUri(here,callback). The SDK completes the token exchange inside the in-app browser session, so the route only needs to return the user to your app:app/callback.tsx -
Add Sign in with YouVersion (Optional)
Drop in the pre-styled button anywhere under the provider. It handles sign-in and sign-out for you:
app/(tabs)/profile.tsxSee YouVersionAuthButton for styling props.
-
Use our Authentication hook (Optional)
When you need a custom sign-in UI, call
signIn()andsignOut()fromuseYVAuthdirectly:SignInButton.tsx
useYVAuth
useYVAuth returns the current authentication state and actions. It must be used under a YouVersionProvider that has the auth prop set, otherwise it throws.
Code
Return value:
| Field | Type | Description |
|---|---|---|
isAuthenticated | boolean | true when a valid access token is present. |
isLoading | boolean | true while tokens are being loaded or restored on startup. |
userInfo | YVUserInfo | null | The signed-in user's profile, or null. |
accessToken | string | null | Current access token, for calling the Platform API on the user's behalf. |
error | Error | null | The most recent auth error, if any. |
signIn | () => Promise<void> | Starts the PKCE sign-in flow in an in-app browser. |
signOut | () => Promise<void> | Clears stored tokens and signs the user out. |
refreshNow | () => Promise<void> | Forces a token refresh. Tokens also refresh automatically. |
YVUserInfo:
Code
Token handling. Access and refresh tokens are stored in expo-secure-store; profile metadata is cached in MMKV. Tokens refresh automatically when they near expiry and when the app returns to the foreground — you don't need to manage this yourself.
Sample app
The apps/example directory contains a working Expo Router app with the provider setup, the callback route, and an auth debug screen.