Skip to main content
The ShareDialog component allows users to share content to Facebook through a native share dialog. It supports multiple content types including links, photos, and videos.

Methods

canShow

Checks if the dialog can be shown with the provided content.
canShow(shareContent: ShareContent): Promise<boolean>
shareContent
ShareContent
required
The content to be shared. Can be ShareLinkContent, SharePhotoContent, or ShareVideoContent.
Promise<boolean>
boolean
Returns true if the dialog can be shown, false otherwise.

Example

import ShareDialog from 'react-native-fbsdk-next';

const canShow = await ShareDialog.canShow({
  contentType: 'link',
  contentUrl: 'https://example.com',
});

if (canShow) {
  // Show the dialog
}

show

Shows the share dialog with the specified content.
show(shareContent: ShareContent): Promise<ShareDialogResult>
shareContent
ShareContent
required
The content to be shared. Can be ShareLinkContent, SharePhotoContent, or ShareVideoContent.
Promise<ShareDialogResult>
ShareDialogResult
A promise that resolves with the share result.
isCancelled
boolean
Whether the user cancelled the share dialog.
postId
string
The ID of the post that was created (if successful).

Example

import ShareDialog from 'react-native-fbsdk-next';

try {
  const result = await ShareDialog.show({
    contentType: 'link',
    contentUrl: 'https://example.com',
    quote: 'Check out this awesome website!',
  });

  if (result.isCancelled) {
    console.log('Share cancelled');
  } else {
    console.log('Share success with postId:', result.postId);
  }
} catch (error) {
  console.log('Share fail with error:', error);
}

setMode

Sets the mode for the share dialog.
setMode(mode: ShareDialogMode): void
mode
ShareDialogMode
required
The mode to use for the share dialog.iOS modes:
  • 'automatic' - Acts with the most appropriate mode that is available
  • 'browser' - Displays the dialog in Safari
  • 'webview' - Displays the dialog in a UIWebView within the app
  • 'native' - The native dialog is used
Android modes:
  • 'automatic' - The mode is determined automatically
  • 'native' - The native dialog is used
  • 'web' - The web dialog is used
  • 'feed' - The feed dialog is used

Example

import ShareDialog from 'react-native-fbsdk-next';

// Set to use native dialog
ShareDialog.setMode('native');

setShouldFailOnDataError

Sets whether or not the native share dialog should fail when it encounters a data error.
setShouldFailOnDataError(shouldFailOnDataError: boolean): void
shouldFailOnDataError
boolean
required
If true, the dialog will fail when it encounters a data error. If false, it will continue.

Example

import ShareDialog from 'react-native-fbsdk-next';

// Fail on data errors
ShareDialog.setShouldFailOnDataError(true);

Types

ShareDialogMode

type ShareDialogMode = ShareDialogModeIOS | ShareDialogModeAndroid;

type ShareDialogModeIOS = 'automatic' | 'browser' | 'webview' | 'native';
type ShareDialogModeAndroid = 'automatic' | 'native' | 'web' | 'feed';

ShareDialogResult

type ShareDialogResult = {
  isCancelled: boolean;
  postId: string;
};

Build docs developers (and LLMs) love