A Vue.js component for sharing links to social networks
Package Exports
vue-social-sharing
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (vue-social-sharing) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Vue Social Sharing
Vue.js renderless components for sharing links on major social networks
Renderless components give you the highest possible control over your markup and styling. This means that vue-social-sharing ship with minimal HTML and no CSS to let you adapt the look and feel of the components to your needs. You can learn more about renderless components in this blog article by @adamwathan.
Understanding social sharing
Before using this package it is important to understand how Social Network handle sharing links on their platform. When you share a link on a Social Network, the Social Network will crawl the link to detect Open Graph meta tags. If you share links that do not contain Open Graph meta tags, the Social Network will not be able to display a rich content for your link. You can refer to the Available properties section of the documentation to check which Social Network accept properties without Open Graph tags.
<ShareNetworknetwork="facebook"url="https://news.vuejs.org/issues/180"title="Say hi to Vite! A brand new, extremely fast development setup for Vue."description="This week, I’d like to introduce you to 'Vite', which means 'Fast'. It’s a brand new development setup created by Evan You."quote="The hot reload is so fast it\'s near instant. - Evan You"hashtags="vuejs,vite">
Share on Facebook
</ShareNetwork>
Available networks and properties
The url and title properties are the only one required for all networks.
General properties
Name
Data Type
Description
tag
String
HTML tag used to render the network component. Default to "a" tag.
Email
Name
Data Type
Description
title
String
Shared as the email subject.
url
String
Shared in the email content.
description
String
Shared in the email content after the url.
Facebook
Name
Data Type
Description
url
String
URL of the shared content.
title
String
Title of the shared content.
description
String
Description of the shared content.
quote
String
A quote from the shared content.
hashtags
String
A list of comma-separated hashtags, only the first one will used by Facebook.
Line
Name
Data Type
Default
Description
title
String
Shared in the message content.
url
String
Shared in the message content after the title.
description
String
Shared in the message content after the url.
LinkedIn
Name
Data Type
Description
url
String
URL of the shared content.
title
String
Title of the shared content.
description
String
Description of the shared content.
Odnoklassniki
Name
Data Type
Description
url
String
URL of the shared content.
title
String
Title of the shared content.
Pinterest
Name
Data Type
Description
url
String
URL of the shared content.
title
String
Title of the shared content.
media
String
URL of an image describing the content.
Reddit
Name
Data Type
Description
url
String
URL of the shared content.
title
String
Title of the shared content.
Skype
Name
Data Type
Description
title
String
Shared in the message content.
url
String
Shared in the message content after the title.
description
String
Shared in the message content after the url.
SMS
Name
Data Type
Description
title
String
Shared in the message content.
url
String
Shared in the message content after the title.
description
String
Shared in the message content after the url.
Telegram
Name
Data Type
Description
title
String
Shared in the message content.
url
String
Shared in the message content after the title.
description
String
Shared in the message content after the url.
Twitter
Name
Data Type
Description
url
String
URL of the shared content.
title
String
Title of the shared content.
hashtags
String
A list of comma-separated hashtags.
twitter-user
String
Twitter user to mention.
Viber
Name
Data Type
Description
title
String
Shared in the message content.
url
String
Shared in the message content after the title.
description
String
Shared in the message content after the url.
VK
Name
Data Type
Description
url
String
URL of the shared content.
title
String
Title of the shared content.
description
String
Description of the shared content.
media
String
URL of an image describing the content.
Weibo
Name
Data Type
Description
url
String
URL of the shared content.
title
String
Title of the shared content.
WhatsApp
Name
Data Type
Description
title
String
Shared in the message content.
url
String
Shared in the message content after the title.
description
String
Shared in the message content after the url.
Available events
Events that are emitted on the vue $root instance:
Name
Data
Description
share_network_open
Network object, shared url
Fired when a sharing popup is open
share_network_change
Network object, shared url
Fired when the user open a new sharing popup while another is already open
share_network_close
Network object, shared url
Fired when a sharing popup is closed or changed by another popup
You can listen to a vue-social-sharing $root event by using the following code:
Vue.$root.$on('share_network_open',function(network, url){// your event code});
Events that are emitted on the local vue-social-sharing instance:
Name
Data
Description
open
Network object, shared url
Fired when a sharing popup is open
change
Network object, shared url
Fired when the user open a new sharing popup while another is already open
close
Network object, shared url
Fired when a sharing popup is closed or changed by another popup
You can listen to a ShareNetwork local event by using the following code: