YouVersionAuthButton component provides a pre-styled button for signing in and out with YouVersion OAuth. It automatically handles authentication flow and displays appropriate content based on auth state.
Basic Usage
Props
Theme for the button.Default: Inherits from provider
Button behavior:
'signIn': Always shows sign in'signOut': Always shows sign out'auto': Shows sign in when not authenticated, sign out when authenticated
"auto"Button size variant:
'default': Full text (“Sign in with YouVersion”)'short': Short text (“Sign in”)'icon': Icon only (YouVersion logo)
"default"Button style:
'default': Solid background'outline': Border with transparent background
"default"Corner style:
'rounded': Default rounded corners'rectangular': More rectangular (0.65rem radius)
"rounded"Custom button text. Overrides default text based on
mode and size.OAuth redirect URL.Deprecated: Use
authRedirectUrl on YouVersionProvider instead.OAuth scopes to request (e.g.,
['profile']).Default: []Callback when authentication fails.
Additional click handler (called before auth flow).
Whether the button is disabled.Default:
falseExamples
Auto Mode (Default)
Shows sign in when not authenticated, sign out when authenticated:Sign In Only
Sign Out Only
Short Size
Icon Only
Outline Variant
Rectangular Corners
Dark Theme
Custom Text
With Scopes
All Options Combined
Button Text
The button displays different text based onmode, size, and auth state:
| Mode | Size | Not Authenticated | Authenticated |
|---|---|---|---|
auto | default | ”Sign in with YouVersion" | "Sign out of YouVersion” |
auto | short | ”Sign in" | "Sign out” |
auto | icon | (icon only) | (icon only) |
signIn | default | ”Sign in with YouVersion" | "Sign in with YouVersion” |
signIn | short | ”Sign in" | "Sign in” |
signOut | default | ”Sign out of YouVersion" | "Sign out of YouVersion” |
signOut | short | ”Sign out" | "Sign out” |
text prop overrides all default text.
Loading State
When authentication is in progress:- Button shows loading spinner overlay
- Button is disabled
- Text remains visible but faded
Authentication Flow
Sign In
- User clicks button
signIn()is called with scopes and redirect URL- User is redirected to YouVersion OAuth
- After approval, redirected back to
authRedirectUrl - Access token stored in auth provider
Sign Out
- User clicks button
signOut()is called- Auth state cleared
- User shown as signed out
Error Handling
ProvideonAuthError to handle authentication errors:
Accessibility
- Button uses semantic
<button>element - Loading state announced to screen readers
- Icon-only variant has
sr-onlytext - Disabled state properly handled
Styling
The button includes:- YouVersion logo icon
- Customizable colors via theme
- Border color based on theme
- Shadow effects
- Hover and active states
- Loading spinner overlay
Related Hooks
- useYVAuth - Access auth state and methods
- YouVersionProvider - Configure authentication
Best Practices
- Always provide
onAuthErrorto handle edge cases - Use
automode for most cases (handles both states) - Use
iconsize in compact UIs like toolbars - Test sign-out flow - ensure users can sign back in
- Configure redirectUrl on provider instead of each button
