PHPackages                             kudashevs/laravel-share-buttons - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. kudashevs/laravel-share-buttons

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

kudashevs/laravel-share-buttons
===============================

A Laravel social media share buttons package.

v7.0.0(2mo ago)4365.6k↓41.3%9MITPHPPHP ^8.2CI passing

Since Dec 11Pushed 2mo ago2 watchersCompare

[ Source](https://github.com/kudashevs/laravel-share-buttons)[ Packagist](https://packagist.org/packages/kudashevs/laravel-share-buttons)[ Docs](https://github.com/kudashevs/laravel-share-buttons)[ RSS](/packages/kudashevs-laravel-share-buttons/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (6)Versions (33)Used By (0)

Laravel Share Buttons
=====================

[](#laravel-share-buttons)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b46f9e4181e7ee22c9eec60ca1bb10d7073787c9aed296d9ab92ad7fd8ba7b42/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b75646173686576732f6c61726176656c2d73686172652d627574746f6e732e737667)](https://packagist.org/packages/kudashevs/laravel-share-buttons)[![Run Tests](https://github.com/kudashevs/laravel-share-buttons/actions/workflows/run-tests.yml/badge.svg)](https://github.com/kudashevs/laravel-share-buttons/actions/workflows/run-tests.yml)[![License MIT](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](LICENSE.md)

This Laravel package provides the possibility to generate share links (social media share buttons) for your site in a flexible and convenient way within seconds. The package was originated from the Laravel Share.

### Available services

[](#available-services)

- Reddit
- LinkedIn
- Facebook
- X (formerly Twitter)
- Bluesky
- Mastodon
- Hacker News
- Tumblr
- Telegram
- WhatsApp
- VKontakte
- Pinterest
- Pocket
- Evernote
- Skype
- Xing
- Copy the link
- Mail the link

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require kudashevs/laravel-share-buttons
```

If you don't use auto-discovery, just add a ShareButtonsServiceProvider to the `config/app.php`

```
'providers' => [
    Kudashevs\ShareButtons\Providers\ShareButtonsServiceProvider::class,
],
```

By default, the `ShareButtons` class instance is bound to the `sharebuttons` alias.

**Note**: Don't forget to publish the configuration file (required) and assets.

```
php artisan vendor:publish --provider="Kudashevs\ShareButtons\Providers\ShareButtonsServiceProvider"
```

> In case of a major change, it is recommended to back up your config file and republish a new one from scratch.

If you want to publish certain assets only, use the `--tag` option with one of the following assets tags: `config`, `css`, `js` (includes all possible js files), `vanilla`, `jquery`.

Assets
------

[](#assets)

By default, this package relies on the `Font Awesome` icons. The buttons' interactivity is implemented in two different ways (via `Vanilla JS` and `jQuery`). However, you can use any custom fonts, icons, or JavaScript.

### Font Awesome and default styles

[](#font-awesome-and-default-styles)

To enable Font Awesome icons, you can load it from a CDN. For more information on how to use Font Awesome, please read the [introduction](https://fontawesome.com/docs/web/setup/get-started).

```

```

To enable the default styles, [publish](#publish) the `css` asset (the command will create a `resources/css/share-buttons.css` file). After publishing, you can copy the file to the `public/css` folder and use it directly. Or you can integrate the css file into your assets building process.

```

```

### JavaScript

[](#javascript)

To enable interaction on social media buttons with JavaScript, [publish](#publish) the `vanilla` asset (the command will create a `resources/js/share-buttons.js` file). After publishing, you can copy the file to the `public/js` folder and use it directly. Or you can integrate this file into your assets building process.

```

```

### jQuery

[](#jquery)

To enable interaction on social media buttons with jQuery, [publish](#publish) the `jquery` asset (the command will create a `resources/js/share-buttons.jquery.js` file). After publishing, you can copy the file to the `public/js` folder and use it directly. Or you can integrate this file into your assets building process.

```

```

Usage
-----

[](#usage)

Let's take a look at a short usage example (you can find a detailed usage example in the [corresponding section](#a-detailed-usage-example)).

```
ShareButtons::page('https://site.com', 'Page title', [
        'title' => 'Page title',
        'rel' => 'nofollow noopener noreferrer',
    ])
    ->facebook()
    ->linkedin(['rel' => 'follow'])
    ->render();
```

The code above will result into the following HTML code:

```

```

### Fluent interface

[](#fluent-interface)

The `ShareButtons` instance provides a fluent interface. The fluent interface is a pattern based on method chaining. To start a method chaining you just need to use one of the methods listed below (the starting point).

```
page($url, $title, $options)              # Creates a chaining with a given URL and a given page title
createForPage($url, $title, $options)     # Does the same (an alias of the page() method)
currentPage($title, $options)             # Creates a chaining with the current page URL and a given page title
createForCurrentPage($title, $options)    # Does the same (an alias of the currentPage() method)

```

### Add buttons

[](#add-buttons)

To generate a single social media button, you just need to add one of the following methods to the [method chaining](#fluent-interface). Each method accepts an array of options (more information about these options in the [local options](#local-options) section).

```
reddit($options)        # Generates a Reddit share button
linkedin($options)      # Generates a LinkedIn share button
facebook($options)      # Generates a Facebook share button
twitter($options)       # Generates an X (former Twitter) share button
bluesky($options)       # Generates a Bluesky share button
mastodon($options)      # Generates a Mastodon share button
hackernews($options)    # Generates a Hacker News share button
tumblr($options)        # Generates a Tumblr share button
telegram($options)      # Generates a Telegram share button
whatsapp($options)      # Generates a WhatsApp share button
vkontakte($options)     # Generates a VKontakte share button
pinterest($options)     # Generates a Pinterest share button
pocket($options)        # Generates a Pocket share button
evernote($options)      # Generates an Evernote share button
skype($options)         # Generates a Skype share button
xing($options)          # Generates a Xing share button
copylink($options)      # Generates a copy to the clipboard share button
mailto($options)        # Generates a send by mail share button

```

These methods are a part of the fluent interface. Therefore, to create multiple social media share buttons you just need to chain them.

### Getting share buttons

[](#getting-share-buttons)

You can use a ShareButtons instance as a string or cast it to a string to get ready-to-use HTML code. However, this is not the best way. If you want to be clear in your intentions, use one of the methods that return generated HTML code. These methods are:

```
render()                # Returns a generated share buttons HTML code
getShareButtons()       # Does the same (an alias of the render() method)
```

### Getting raw links

[](#getting-raw-links)

Sometimes, you may only want the raw links without any HTML. In such a case, just use the `getRawLinks` method.

```
getRawLinks()           # Returns an array of generated links
```

Parameters
----------

[](#parameters)

There is the possibility of providing different options to style and decorate the resulting HTML code at different levels.

### Global options

[](#global-options)

Every time a chaining method is called, it accepts several arguments, including a page URL (depending on the method), a page title, and an array of options. These options are global because they change the representation of all share buttons. These options are:

```
'block_prefix' => 'tag'          # Sets a share buttons block prefix (default is )
'block_suffix' => 'tag'          # Sets a share buttons block suffix (default is )
'element_prefix' => 'tag'        # Sets an element prefix (default is empty)
'element_suffix' => 'tag'        # Sets an element suffix (default is empty)
'id' => 'value'                  # Adds an HTML id attribute to the output links
'class' => 'value'               # Adds an HTML class attribute to the output links
'title' => 'value'               # Adds an HTML title attribute to the output links
'rel' => 'value'                 # Adds an HTML rel attribute to the output links

```

### Local options

[](#local-options)

Any of the [share button methods](#add-buttons), that generates a button, accepts several arguments. These options are local because they will be applied to a specific element only. The local options have a **higher priority**. Therefore, they will overwrite the global options if there is any overlap. At the moment, the package supports the following local options:

```
'text' => 'value'                # Adds a link text to a generated URL (overrides global page title)
'id' => 'value'                  # Adds an HTML id attribute to the button link
'class' => 'value'               # Adds an HTML class attribute to the button link
'title' => 'value'               # Adds an HTML title attribute to the button link
'rel' => 'value'                 # Adds an HTML rel attribute to the button link
'summary' => 'value'             # Adds a summary text to the URL (linkedin button only)

```

Configuration
-------------

[](#configuration)

The configuration settings are located in the `config/share-buttons.php` file.

### Representation section

[](#representation-section)

This section contains settings related to the "container" in which the social media buttons will be displayed.

```
'block_prefix' => 'tag'         # Sets a block prefix (default is )
'block_suffix' => 'tag'         # Sets a block suffix (default is )
'element_prefix' => 'tag'       # Sets an element prefix (default is empty)
'element_suffix' => 'tag'       # Sets an element suffix (default is empty)

```

### Share buttons section

[](#share-buttons-section)

Each social media share button has its own individual configuration settings.

```
'url' => 'value'                # A share button URL template (is used to generate a button's URL)
'text' => 'value'               # A default text to be added to the url (is used when the page title is empty)
'extra' => [                    # Extra options that are required by some specific buttons
    'summary' => 'value'        # A default summary to be added to the url (linkedin only)
    'raw' => 'value'            # A boolean defines whether to skip the URL-encoding of the url
    'hash' => 'value'           # A boolean defines whether to use a hash instead of the url
]

```

**Note**: a text value might contain a `url` element, which will be replaced by the page url while processing.

### Templates section

[](#templates-section)

Each share button has a corresponding link template. A template contains several elements that will be substituted with data from different arguments and options. The format of these elements depends on the `templater` setting. By default, these elements are:

```
:url                            # Will be replaced with a prepared URL
:id                             # Will be replaced with an id attribute
:class                          # Will be replaced with a class attribute
:title                          # Will be replaced with a title attribute
:rel                            # Will be replaced with a rel attribute

```

### Templaters section

[](#templaters-section)

For processing different templates and substitute elements in them, the package uses templaters (template engines). By default, these options are optional (if no value provided, the default templater will be used).

```
'templater'                     # A template engine for processing link templates
'url_templater'                 # A template engine for processing share buttons URLs

```

A detailed usage example
------------------------

[](#a-detailed-usage-example)

To summarize all of the information from above, let's take a look at a real-life example. We begin with one of the methods that start the fluent interface, and we provide some global options. Then, we add some specific methods that generate social media share buttons. At this step, we can provide any local options, as it is done in the `linkedin()` method. Finally, we finish the fluent interface chain with one of the methods that return the resulting HTML code.

```
ShareButtons::page('https://site.com', 'Page title', [
        'block_prefix' => '',
        'block_suffix' => '',
        'element_prefix' => '',
        'element_suffix' => '',
        'class' => 'my-class',
        'id' => 'my-id',
        'title' => 'my-title',
        'rel' => 'nofollow noopener noreferrer',
    ])
    ->facebook()
    ->linkedin(['id' => 'linked', 'class' => 'hover', 'rel' => 'follow', 'summary' => 'cool summary'])
    ->render();
```

The code above will result into the following HTML code:

```

```

Testing
-------

[](#testing)

```
composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

License
-------

[](#license)

The MIT License (MIT). Please see the [License file](LICENSE.md) for more information.

###  Health Score

60

—

FairBetter than 98% of packages

Maintenance87

Actively maintained with recent releases

Popularity44

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 92.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~51 days

Recently: every ~127 days

Total

32

Last Release

63d ago

Major Versions

v2.2.0 → v3.0.02022-12-05

v3.3.0 → v4.0.02023-08-14

v4.0.0 → v5.0.02024-03-17

v5.3.0 → v6.0.02024-12-15

v6.1.1 → v7.0.02026-05-01

PHP version history (4 changes)v1.0.0PHP ^7.3|^8.0

v3.0.0PHP ^7.4|^8.0

v6.0.0PHP ^8.1

v7.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/8cb0dfa9fab98bfb2cb6c697744ea5c1f7f57ffd6b0a498df6a17223912b617a?d=identicon)[Sergey Kudashev](/maintainers/Sergey%20Kudashev)

---

Top Contributors

[![kudashevs](https://avatars.githubusercontent.com/u/15892462?v=4)](https://github.com/kudashevs "kudashevs (1377 commits)")[![jorenvh](https://avatars.githubusercontent.com/u/8791625?v=4)](https://github.com/jorenvh "jorenvh (41 commits)")[![pqrs](https://avatars.githubusercontent.com/u/1423685?v=4)](https://github.com/pqrs "pqrs (30 commits)")[![sandervankasteel](https://avatars.githubusercontent.com/u/17492906?v=4)](https://github.com/sandervankasteel "sandervankasteel (25 commits)")[![rabol](https://avatars.githubusercontent.com/u/1177191?v=4)](https://github.com/rabol "rabol (3 commits)")[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (3 commits)")[![leMaur](https://avatars.githubusercontent.com/u/2118799?v=4)](https://github.com/leMaur "leMaur (2 commits)")[![samuelhgf](https://avatars.githubusercontent.com/u/16768378?v=4)](https://github.com/samuelhgf "samuelhgf (2 commits)")[![timopaul](https://avatars.githubusercontent.com/u/16575322?v=4)](https://github.com/timopaul "timopaul (1 commits)")[![faustbrian](https://avatars.githubusercontent.com/u/22145591?v=4)](https://github.com/faustbrian "faustbrian (1 commits)")[![easoblue](https://avatars.githubusercontent.com/u/77021478?v=4)](https://github.com/easoblue "easoblue (1 commits)")

---

Tags

laravelshare-buttonssocial-media-buttonslaravelsharesocial linksshare buttons

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/kudashevs-laravel-share-buttons/health.svg)

```
[![Health](https://phpackages.com/badges/kudashevs-laravel-share-buttons/health.svg)](https://phpackages.com/packages/kudashevs-laravel-share-buttons)
```

###  Alternatives

[jorenvanhocht/laravel-share

Optional package for Laravel to generate social share links.

5341.2M5](/packages/jorenvanhocht-laravel-share)[chencha/share

Share links with Laravel

185274.2k](/packages/chencha-share)[ryannielson/shareable

A Laravel 4 package to make it easy to add social sharing buttons to your application.

222.8k](/packages/ryannielson-shareable)[yaro/soc-share

Social network share link builder

102.0k](/packages/yaro-soc-share)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
