New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

vue-social-sharing

Package Overview
Dependencies
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-social-sharing

A Vue.js component for sharing links to social networks

  • 3.0.0-beta.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
29K
decreased by-1.16%
Maintainers
1
Weekly downloads
 
Created
Source

Vue Social Sharing

Release Build Status Coverage Status Downloads License Vue 1 Vue 2

Less than 2.5kb gzipped

For Vue.js prior to v2.x use vue-social-sharing v0.x
For Vue.js v2.x support use vue-social-sharing v2.x
For SSR and Vue.js v3.x support use vue-social-sharing v3.x

Demo

What is a renderless component?

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.

Installation

# Yarn
yarn add vue-social-sharing

# NPM
npm install --save vue-social-sharing

# Bower
bower install vue-social-sharing

Usage

Loading the library

Browserify / Webpack
import VueSocialSharing from 'vue-social-sharing'

Vue.use(SocialSharing);
HTML
<script src="/dist/vue-social-sharing.js"></script>

Using the Share Network component

<ShareNetwork
    network="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
  • Facebook
  • Line
  • LinkedIn
  • Odnoklassniki
  • Pinterest
  • Reddit
  • Skype
  • Telegram
  • Twitter
  • Viber
  • Vk
  • Weibo
  • Whatsapp
  • Custom
Available properties

List of available props to use in the component:

PropData TypeDefaultDescription
urlStringcurrentURL to share.
titleStringSharing title (when available).
descriptionStringSharing description (when available).
quoteStringFacebook quote (Facebook only).
hashtagsStringA list of comma-separated hashtags (Twitter and Facebook).
twitter-userStringTwitter user (Twitter only).
mediaStringUrl to a media (Pinterest only).
tagString"a"Tag the network component should render.
Facebook only accept one hashtag. If you define multiple hashtags, only the first one will be passed to facebook
Available events

Events that are emitted on the vue $root instance:

NameDataDescription
share_network_openNetwork object, shared urlFired when a sharing popup is open
share_network_changeNetwork object, shared urlFired when the user open a new sharing popup while another is already open
share_network_closeNetwork object, shared urlFired 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:

NameDataDescription
openNetwork object, shared urlFired when a sharing popup is open
changeNetwork object, shared urlFired when the user open a new sharing popup while another is already open
closeNetwork object, shared urlFired when a sharing popup is closed or changed by another popup

You can listen to a ShareNetwork local event by using the following code:

<ShareNetwork @open="open()" @change="change()" @close="close()" />

Note that the share_network_close event will not be fired for the WhatsApp, SMS and Email sharers.

Extending the network list

In version 3.x you can extend and override the list of available networks. You can see a working example of the feature in the examples/index.js file:

import Vue from 'vue'
import VueSocialSharing from '@/vue-social-sharing'

Vue.use(VueSocialSharing, {
  networks: {
    fakeblock: {
      sharer: 'https://fakeblock.com/share?url=@url&title=@title',
      type: 'popup'
    }
  }
})


new Vue({
  el: '#app',
})

You can choose between two behavior type while defining a custom network:

TypeEffect
popupOpen the sharing link in a new popup
directOpen the sharing link directly (suitable for mobile apps sharing, emails, sms, ...)

Feature request

Feel free to open an issue to ask for a new social network support.

Changelog

Detailed changes for each release can be found in CHANGELOG.md.

Issues

Please make sure to read the Issue Reporting Checklist before opening an issue. Issues not conforming to the guidelines may be closed immediately.

Contribution

Please make sure to read the Contributing Guide before making a pull request.

License

MIT

Keywords

FAQs

Package last updated on 15 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc