LoginButton component is a pre-built UI component that initiates Facebook Login or Logout when pressed. It automatically shows the appropriate button based on the user’s login state.
Import
Props
permissions
The permissions to request when the login button is pressed.Array<string>Default:
['public_profile']Platform: Both
Example
Common Permissions
public_profile- Basic profile information (name, profile picture)email- User’s email addressuser_friends- List of friends who use your appuser_birthday- User’s birthdayuser_photos- User’s photosuser_posts- User’s posts
onLoginFinished
Callback invoked when login completes, fails, or is cancelled.Platform: Both
Parameters
| Parameter | Type | Description |
|---|---|---|
error | Record<string, unknown> | Error object if login failed, null otherwise |
result | LoginResult | Result object containing login status and permissions |
Example
onLogoutFinished
Callback invoked when logout completes.Platform: Both
Example
loginTrackingIOS
The desired tracking preference for iOS login. Use'limited' for Limited Login (privacy-focused) or 'enabled' for traditional login.
'enabled' | 'limited'Default:
'enabled'Platform: iOS only
iOS 14.5+ requires Limited Login when users opt out of App Tracking Transparency. Setting this to
'limited' ensures your app works for all users.Example
nonceIOS
An optional nonce to use for iOS login validation. A unique nonce is automatically generated if not provided.stringPlatform: iOS only
Example
loginBehaviorAndroid
The behavior to use when attempting login on Android.'native_with_fallback' | 'native_only' | 'web_only'Default:
'native_with_fallback'Platform: Android only
'native_with_fallback'- Try Facebook app, fall back to web dialog'native_only'- Only use Facebook app'web_only'- Only use web dialog
Example
defaultAudience
The default audience for posts made by the application.'friends' | 'everyone' | 'only_me'Default:
'friends'Platform: Both
'friends'- Only friends can see posts'everyone'- All Facebook users can see posts'only_me'- Only the user can see posts
Example
tooltipBehaviorIOS
The desired tooltip behavior for iOS.'auto' | 'force_display' | 'disable'Default:
'auto'Platform: iOS only
'auto'- Show tooltip automatically based on Facebook’s logic'force_display'- Always show the tooltip'disable'- Never show the tooltip
Example
style
Custom styling for the button.ViewStylePlatform: Both
The default button size is 190x30. You can customize the size, but the button content (text and icon) is controlled by Facebook and cannot be changed.
Example
testID
Test identifier for automated testing.stringPlatform: Both
Example
Complete Example
See Also
Login Methods
Learn about different login methods
LoginManager
Programmatic login with LoginManager
Limited Login
Understand iOS Limited Login
AccessToken
Work with access tokens