Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Vue 3 social sharing plugin

License

NotificationsYou must be signed in to change notification settings

hedint/vue3-social-sharing

Repository files navigation

npm versionnpm downloadsLicenseVue 2

Style agnostic Vue 3 plugin for social sharing your links on major social networks.Typescript friendly!
Basically it's a modern fork ofvue-social-sharing library.If you are using vue 2 you should use that library.

Available networks

supported social networks

BaiduBlueskyBufferEmailEverNoteFacebookFlipBoardHackerNewsInstaPaperLineLinkedInMessengerOdnoklassnikiPinterestPocketRedditSkypeSMSStumbleUponTelegramThreadsTumblrTwitterXViberVKWeiboWhatsAppWordpressXingYammer

Installation

# Using pnpmpnpm add vue3-social-sharing# Using yarnyarn add vue3-social-sharing# Using npmnpm install vue3-social-sharing

Usage

As composable

<script setup lang="ts">import {useShareLink}from"vue3-social-sharing";const {shareLink}=useShareLink();const share= ()=> {shareLink({      network:"facebook",      url:"https://example.com"    })  }</script><template>  <main>    <span@click="share">Share on facebook</span>  </main></template>

As Vue plugin

You can use this package as aregular vue plugin.

importVue3SocialSharingPluginfrom"vue3-social-sharing";constapp=createApp(App);app.use(Vue3SocialSharingPlugin);app.mount("#app");

After you'll be able to use ShareNetwork component in your app like this:

<share-network    network="facebook"    url="https://example.com"v-slot="{share }"  >    <span @click="share">Share on Facebook</span></share-network>

Here you can findthe demo page.

As renderless component

<script setup lang="ts">import {ShareNetwork }from"vue3-social-sharing";</script><template>  <ShareNetworknetwork="facebook"url="https://example.com"v-slot="{ share }"  >    <span@click="share">Share on Facebook</span>  </ShareNetwork></template>

Available properties

Theurl is the only property required for all networks.

PropTypeDescription
url*StringURL to share.
network*StringNetwork name.
titleStringSharing title (if available).
descriptionStringSharing description (if available).
quoteStringFacebook quote (Facebook only).
hashtagsStringA list of comma-separated hashtags (Twitter and Facebook).
twitter-userStringTwitter user (Twitter only).
mediaStringUrl to a media (Pinterest, VK, Weibo, and Wordpress).

Custom network

You are able to add your custom network by providing shareNetworks option to the vue plugin.

importVue3SocialSharingPluginfrom"vue3-social-sharing";constapp=createApp(App);app.use(Vue3SocialSharingPlugin,{shareNetworks:{"my-network":"https://example.com?url=@u&title=@t"}});app.mount("#app");

Available template properties in your link:

  • @u = url
  • @t = title
  • @d = description
  • @q = quote
  • @h = hashtags
  • @m = media
  • @tu = twitterUser

You can find a full example inthe demo.

More examples?

You can find more examples in the playground dir of this repo.

Feature request

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

CONTRIBUTING

  • Fork the repo
  • Create a feature branch with an issue number if it's related to any existing issue
  • Run npm install
  • Make you changes
  • Run the testsnpm run test (Ofc you can write your own tests if you feel the need)
  • Update thedocumentation if needed
  • Runnpm run build, commit your changes and make a pull request.

About

Vue 3 social sharing plugin

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp