VuePress EcosystemVuePress Ecosystem
  • Theme Guidelines
  • theme-default
  • Hope Theme
  • Plume Theme
  • Reco Theme
  • Feature Plugins
  • Markdown Plugins
  • Search Plugins
  • Blog Plugins
  • PWA Plugins
  • Analytics Plugins
  • SEO Plugins
  • Development Plugins
  • Tool Plugins
  • AI Plugins
  • @vuepress/helper
  • @vuepress/test-utils
  • English
  • 简体中文
GitHub
  • Theme Guidelines
  • theme-default
  • Hope Theme
  • Plume Theme
  • Reco Theme
  • Feature Plugins
  • Markdown Plugins
  • Search Plugins
  • Blog Plugins
  • PWA Plugins
  • Analytics Plugins
  • SEO Plugins
  • Development Plugins
  • Tool Plugins
  • AI Plugins
  • @vuepress/helper
  • @vuepress/test-utils
  • English
  • 简体中文
GitHub
  • back-to-top
  • catalog
  • copy-code
  • copyright
  • icon
  • media
  • medium-zoom
  • notice
  • nprogress
  • photo-swipe
  • share
  • watermark

share

@vuepress/plugin-share

Add share buttons to your site, so visitors can share pages to social platforms, by email, or as a QR code.

Usage

npm i -D @vuepress/plugin-share@next
.vuepress/config.ts
import { sharePlugin } from '@vuepress/plugin-share'

export default {
  plugins: [
    sharePlugin({
      // options
    }),
  ],
}

The plugin registers a global Share component. Add it to any page:

<Share />

Guide

Share Services

By default, the plugin renders buttons for X (formerly Twitter), Facebook, Reddit, Telegram, WhatsApp, and email.

You can choose the buttons to display on a page with the services prop. It accepts a comma separated string or an array of service names:

<Share services="qq,weibo" />

<Share :services="['qq', 'weibo']" />

The following built-in services are available:

NamePlatformNamePlatform
bufferBufferdoubanDouban
emailEmailevernoteEvernote
facebookFacebookflipboardFlipboard
lineLINElinkedinLinkedIn
messengerMessengerpinterestPinterest
qqQQqrcodeQR code
qzoneQzoneredditReddit
skypeSkypesmsSMS
snapchatSnapchattelegramTelegram
tumblrTumblrvkVK
weiboWeibowhatsappWhatsApp
wordpressWordPressxX

Every built-in service is available to the component. The services option only decides which buttons are displayed by default, so <Share services="qq" /> works without listing qq in the plugin options.

Custom Services

You can add a custom service in the services option:

.vuepress/config.ts
import { sharePlugin } from '@vuepress/plugin-share'

export default {
  plugins: [
    sharePlugin({
      services: [
        'x',
        {
          name: 'mastodon',
          link: 'https://mastodon.social/share?text=[title]&url=[url]',
          shape: '<svg>...</svg>',
          color: '#6364ff',
        },
      ],
    }),
  ],
}

A custom service requires name, link, and shape. It also supports label, color, icon, and action:

  • label overrides the accessible label and tooltip of the button, which default to name.
  • shape is the plain icon. It can be an SVG string, an image URL, or a font icon class.
  • color is the background color used by the colorful icon.
  • icon overrides the icon used when colorful is enabled.
  • action is the behavior of the button. See Actions.

Custom services are only known to the client when they are provided in the plugin options. To display them by name, pass their names in the services prop:

<Share services="x,mastodon" />

Share Data

The link of each service can contain variables wrapped in brackets. They are replaced with the data of the current page:

VariableDescription
titlePage title
descriptionPage description
urlPage URL
excerptPage excerpt
summaryPage summary
tagsPage tags, joined by commas
coverPage cover
imageFirst image on the page

description, excerpt, summary, cover, and tags fall back to the matching page frontmatter field, and description also falls back to the page meta tags:

---
description: A page about VuePress
tag:
  - vuepress
  - plugin
cover: /images/cover.png
---

You can override the title, description, excerpt, summary, cover, and tags per page with props that receive the current page. url and image are always derived from the page:

<Share
  :title-getter="(page) => page.title.toUpperCase()"
  :tag-getter="() => 'vuepress'"
/>

Actions

A service opens its link in a popup window by default. The built-in QR code service uses qrcode, and the email service opens a new tab. For custom services, set action to one of:

  • popup: Opens the link in a centered popup window.
  • open: Opens the link in a new tab.
  • navigate: Opens the link in the current tab.
  • qrcode: Shows a QR code of the link.

A custom qrcode service receives its link verbatim, so it is not percent-encoded.

Appearance

Buttons are muted and colored on hover. Use colorful to render the brand color:

<Share colorful />

Use inline to remove the vertical margin, which is useful when the buttons are placed in a paragraph or a layout slot:

<Share inline />

Options

servicesShareService[]

Services to display by default. Built-in services are selected by name, and a custom service is provided as an object.

Defaults to x, facebook, reddit, telegram, whatsapp, and email.

See also: Share Services and Custom Services.

xUserNamestring

X username used by the via parameter of the built-in x service.

Component Props

servicesstring | (string | ShareServiceOptions)[]

Services to display. It can be a comma separated string or an array of names and custom service objects.

Defaults to the services plugin option.

titleGetter(page: PageData) => string

Getter for the share title.

Defaults to the page title.

descriptionGetter(page: PageData) => string | null | undefined

Getter for the share description.

Defaults to the description frontmatter and meta tags.

excerptGetter(page: PageData) => string | null | undefined

Getter for the share excerpt.

Defaults to the page excerpt and excerpt frontmatter.

summaryGetter(page: PageData) => string | null | undefined

Getter for the share summary.

Defaults to the page summary and summary frontmatter.

coverGetter(page: PageData) => string | null | undefined

Getter for the share cover.

Defaults to the page cover, cover frontmatter, and og:image meta tag.

tagGetter(page: PageData) => string | string[] | null | undefined

Getter for the share tags.

Defaults to the tag and tags frontmatter.

inlineboolean

Whether to display the buttons inline.

colorfulboolean

Whether to use colorful icons.

Edit this page on GitHub
Last Updated: 11/22/26, 1:57 AM
Contributors: Mister-Hope
Prev
photo-swipe
Next
watermark