Complete reference for all components, hooks, and types
Root provider component that initializes Facebook SDK
| Name | Type | Required | Description |
|---|---|---|---|
| appId | string | Yes | Your Facebook App ID |
| version | string | v18.0 | Facebook SDK version |
| language | string | en_US | Locale for SDK |
| debug | boolean | false | Enable debug mode |
| xfbml | boolean | true | Parse XFBML tags |
| cookie | boolean | true | Enable cookies |
| lazy | boolean | false | Lazy load SDK |
| pixel | PixelOptions | No | Facebook Pixel configuration |
<FacebookProvider appId="123456789" version="v18.0" language="en_US" pixel={{ pixelId: "987654321" }}> {children}</FacebookProvider>Modern unified Facebook login component (replaces LoginButton and FacebookLogin)
| Name | Type | Required | Description |
|---|---|---|---|
| scope | string[] | ['public_profile', 'email'] | Array of permissions |
| fields | string[] | [] | Profile fields to fetch |
| onSuccess | (response) => void | No | Success callback |
| onError | (error) => void | No | Error callback |
| onProfileSuccess | (profile) => void | No | Profile success callback |
| children | ReactNode | Function | No | Content or render function |
| as | ElementType | ComponentType | button | Component to render as |
| disabled | boolean | false | Disable login |
| className | string | No | CSS class name |
| returnScopes | boolean | false | Return granted scopes |
| authType | string[] | No | Auth type parameters |
| rerequest | boolean | false | Re-request permissions |
| reauthorize | boolean | false | Re-authorize permissions |
// Basic usage with Tailwind<Login scope={['email', 'public_profile']} onSuccess={(response) => console.log('Success:', response)} onError={(error) => console.error('Error:', error)} className="bg-blue-600 text-white px-4 py-2 rounded-lg hover:bg-blue-700"> Continue with Facebook</Login>
// Children as function pattern<Login scope={['public_profile', 'email']} fields={['name', 'email', 'picture']} onSuccess={handleSuccess} onProfileSuccess={(profile) => console.log('Profile:', profile)}> {({ onClick, isLoading, isDisabled }) => ( <button onClick={onClick} disabled={isDisabled} className={`btn ${isLoading ? 'loading' : ''}`} > {isLoading ? 'Connecting...' : 'Login with Facebook'} </button> )}</Login>
// Custom element<Login as="a" href="#" className="text-blue-600 hover:underline"> Connect Facebook Account</Login>Share dialog component
| Name | Type | Required | Description |
|---|---|---|---|
| href | string | Yes | URL to share |
| hashtag | string | No | Hashtag for the post |
| quote | string | No | Quote to include |
| onSuccess | () => void | No | Success callback |
| onError | (error) => void | No | Error callback |
| children | RenderProp | Yes | Render function |
<Share href="https://example.com"> {({ handleClick }) => ( <button onClick={handleClick}>Share</button> )}</Share>Facebook like button
⚠️ EU/EEA/UK users will not see this component unless logged into Facebook and have consented to cookies.
| Name | Type | Required | Description |
|---|---|---|---|
| href | string | Yes | URL to like |
| layout | LikeLayout | standard | Button layout style |
| size | "small" | "large" | small | Button size |
| showFaces | boolean | false | Show profile photos |
| share | boolean | false | Include share button |
| colorScheme | "light" | "dark" | light | Color scheme |
<Like href="https://example.com" layout="button_count" size="large" showFaces={true} share={true}/>Embedded Facebook comments
EU/EEA/UK users must be logged into Facebook AND have consented to cookies. Component will not be visible otherwise.
| Name | Type | Required | Description |
|---|---|---|---|
| href | string | Yes | URL for comments |
| numPosts | number | 10 | Number of posts to show |
| orderBy | "social" | "reverse_time" | "time" | social | Sort order |
| width | string | number | 550 | Plugin width |
| colorScheme | "light" | "dark" | light | Color scheme |
<Comments href="https://example.com/article" numPosts={20} orderBy="social"/>Embed a Facebook page in your website
| Name | Type | Required | Description |
|---|---|---|---|
| href | string | Yes | Facebook page URL |
| tabs | string | timeline | Comma-separated list of tabs |
| width | number | 340 | Plugin width |
| height | number | 500 | Plugin height |
| smallHeader | boolean | false | Use small header |
| hideCover | boolean | false | Hide cover photo |
| showFacepile | boolean | true | Show friends faces |
<Page href="https://www.facebook.com/YourPage" tabs="timeline,events,messages" width={500} height={600}/>Embed a Facebook post in your website
| Name | Type | Required | Description |
|---|---|---|---|
| href | string | Yes | Facebook post URL |
| width | number | 500 | Plugin width |
| showText | boolean | true | Show post text |
<EmbeddedPost href="https://www.facebook.com/user/posts/123456789" width={500} showText={true}/>Embed a Facebook video in your website
| Name | Type | Required | Description |
|---|---|---|---|
| href | string | Yes | Facebook video URL |
| width | number | 500 | Plugin width |
| showText | boolean | true | Show video description |
| allowFullScreen | boolean | true | Allow fullscreen |
<EmbeddedVideo href="https://www.facebook.com/facebook/videos/123456789" width={500} showText={true}/>Display the number of comments for any URL
| Name | Type | Required | Description |
|---|---|---|---|
| href | string | Yes | URL to count comments for |
<CommentsCount href="https://example.com/article" />Alternative share button implementation
| Name | Type | Required | Description |
|---|---|---|---|
| href | string | Yes | URL to share |
| layout | string | button | Button layout |
| size | "small" | "large" | small | Button size |
| children | ReactNode | No | Button content |
<ShareButton href="https://example.com"> Share this content</ShareButton>Standalone Facebook Pixel provider (can be used independently)
| Name | Type | Required | Description |
|---|---|---|---|
| pixelId | string | Yes | Facebook Pixel ID |
| autoConfig | boolean | true | Enable automatic configuration |
| debug | boolean | false | Enable debug logging |
| advancedMatching | Record<string, any> | No | Advanced matching parameters |
| lazy | boolean | false | Delay initialization |
| children | ReactNode | Yes | Child components |
<FacebookPixelProvider pixelId="123456789" autoConfig={true} debug={true} advancedMatching={{ em: 'user@example.com', // hashed email ph: '+1234567890' // hashed phone }}> {children}</FacebookPixelProvider>Access Facebook SDK instance and state
isLoadingerrorinitapiparseconst { isLoading, error, api } = useFacebook();
useEffect(() => { if (api) { api.getLoginStatus((response) => { console.log(response); }); }}, [api]);Facebook login functionality
loginlogoutisLoadingerrorconst { login, logout, isLoading } = useLogin();
const handleLogin = async () => { const response = await login({ scope: 'email,public_profile' }); console.log(response);};Fetch user profile data
profileloadingerrorfetchProfileconst { profile, loading, fetchProfile } = useProfile();
if (profile) { console.log(profile.name, profile.email);}Facebook Pixel tracking with comprehensive event support
isLoadingerrorinitpixelpageViewtracktrackCustomgrantConsentrevokeConsentfbqconst { track, trackCustom, pageView, grantConsent } = usePixel();
// Track standard Facebook eventstrack('Purchase', { value: 25.00, currency: 'USD', contents: [{ id: 'product-123', quantity: 1 }]});
track('ViewContent', { content_ids: ['product-123'], content_type: 'product', value: 25.00, currency: 'USD'});
// Track custom eventstrackCustom('NewsletterSignup', { email_domain: 'gmail.com'});
// GDPR compliancegrantConsent();
// Manual page view trackingpageView();Automatic page view tracking with route change support
pageViewisLoading// Auto-track on mountusePageView();
// Custom configurationusePageView({ trackOnMount: true, trackOnRouteChange: true, data: { custom_param: 'value' }});
// Manual tracking onlyconst { pageView } = usePageView({ trackOnMount: false });pageView(); // Trigger manuallyDynamic locale management
localesetLocaleconst { locale, setLocale } = useLocale();
await setLocale('es_ES');Share dialog functionality
shareisLoadingerrorconst { share } = useShare();
await share({ href: 'https://example.com', hashtag: '#react'});Configuration options for Facebook SDK
interface FacebookOptions { appId: string; version?: string; language?: string; debug?: boolean; xfbml?: boolean; cookie?: boolean; lazy?: boolean;}Facebook Pixel configuration
interface PixelOptions { pixelId: string; autoConfig?: boolean; debug?: boolean; advancedMatching?: Record<string, any>;}Standard Facebook Pixel event names
type PixelEventName = | 'PageView' | 'ViewContent' | 'Search' | 'AddToCart' | 'AddToWishlist' | 'InitiateCheckout' | 'AddPaymentInfo' | 'Purchase' | 'Lead' | 'CompleteRegistration' | 'Contact' | 'CustomizeProduct' | 'Donate' | 'FindLocation' | 'Schedule' | 'StartTrial' | 'SubmitApplication' | 'Subscribe';Event data for Facebook Pixel tracking
interface PixelEventData { // Standard parameters value?: number; currency?: string; content_name?: string; content_category?: string; content_ids?: string[]; content_type?: string; contents?: Array<{ id: string; quantity?: number; item_price?: number; }>; // E-commerce specific num_items?: number; search_string?: string; status?: string; // Custom parameters [key: string]: any;}Facebook login response
interface LoginResponse { authResponse?: { accessToken: string; userID: string; expiresIn: number; signedRequest: string; }; status: 'connected' | 'not_authorized' | 'unknown';}Context interface for Facebook Pixel provider
interface FacebookPixelContextInterface { isLoading: boolean; error: Error | undefined; init: () => Promise<void>; pixel: FacebookPixel | undefined; pageView: () => void; track: (eventName: PixelEventName, data?: PixelEventData) => void; trackCustom: (eventName: string, data?: PixelEventData) => void; grantConsent: () => void; revokeConsent: () => void; fbq: (...args: any[]) => void;}