Skip to content

Instantly share code, notes, and snippets.

@eymeen
Created September 11, 2024 14:06
Show Gist options
  • Select an option

  • Save eymeen/3c5ebefca2bc645603b0a0ea0d559ca1 to your computer and use it in GitHub Desktop.

Select an option

Save eymeen/3c5ebefca2bc645603b0a0ea0d559ca1 to your computer and use it in GitHub Desktop.
How to make share button in a website

the navigator.share function allows you to fire the share action. Like this:

navigator.share({
  title: 'Title',
  text: 'Text',
  url: 'https://www.example.com' // required
})

you can also do:

.then(() => {
  console.log('Share was Successful!');
}).catch((error) => {
  console.log('Error Sharing:', error);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment