Developer tools
RU EN

System Share

share() method for opening native share dialog

Ready to run
await navigator.share({
  title: 'Заголовок',
  text: 'Текст для обмена',
  url: 'https://example.com'
});

Parameters:

  • title Optional - title to share
  • text Optional - text to share
  • url Optional - URL to share
  • files Optional - array of files to share (File[])

Method returns a Promise that resolves when sharing is successful or rejects if the user cancels the operation.

Note: API is only available in secure contexts (HTTPS) and requires user gesture.

canShare() method for checking if sharing is possible

Ready to run
if (navigator.canShare) {
  const canShare = navigator.canShare({
    title: 'Заголовок',
    text: 'Текст',
    url: 'https://example.com'
  });
  console.log('Can share:', canShare);
}

Method checks if the specified data can be shared. Returns true or false.

Parameters are similar to share() method.

Links