nasirkhan / laravel-sharekit
Reusable social sharing Blade components for Laravel with themeable styles, metadata auto-detection, and page-scoped assets.
Package info
github.com/nasirkhan/laravel-sharekit
Language:Blade
pkg:composer/nasirkhan/laravel-sharekit
Requires
- php: ^8.3
- illuminate/support: ^11.0|^12.0|^13.0
- illuminate/view: ^11.0|^12.0|^13.0
Requires (Dev)
- orchestra/testbench: ^9.0|^10.0|^11.0
- phpunit/phpunit: ^11.0|^12.0
This package is auto-updated.
Last update: 2026-04-07 18:58:47 UTC
README
Laravel Sharekit provides reusable Blade-powered social sharing buttons for Laravel applications.
It is designed to work well as a standalone package or alongside packages like nasirkhan/laravel-cube when you want social sharing on selected frontend pages without loading sharing assets globally.
Features
- Blade component for grouped share buttons
- Metadata auto-detection from page meta tags and document data
- Per-instance prop overrides for URL, title, description, image, hashtags, and more
- Page-scoped CSS and JS loaded only when the component is rendered
- Native Web Share API support where available
- Popup-based sharing for common social networks
- Copy-link action with feedback state
- Configurable default theme, labels, enabled networks, popup size, and stack names
- Theme-ready structure with
defaultandtailwindpresets, with room for future themes
Requirements
- PHP ^8.3
- Laravel ^11.0 || ^12.0 || ^13.0
Installation
Install the package via Composer:
composer require nasirkhan/laravel-sharekit
The package uses Laravel package discovery, so no manual provider registration is needed.
Publish Configuration
If you want to customize defaults, publish the config file:
php artisan vendor:publish --tag=sharekit-config
If you want to override the package Blade views:
php artisan vendor:publish --tag=sharekit-views
Layout Requirements
Sharekit pushes page-scoped CSS and JS into Blade stacks.
Your layout should include:
@stack('after-styles')
inside the <head> section, and:
@stack('after-scripts')
before the closing </body> tag or in your layout footer.
These stack names are configurable in config/sharekit.php.
Basic Usage
Render the buttons with page metadata auto-detection:
<x-sharekit::buttons />
This is useful when your page already includes tags like:
og:urlog:titleog:descriptionog:imagetwitter:titletwitter:descriptiontwitter:imagelink[rel="canonical"]
Usage With Overrides
<x-sharekit::buttons :url="route('posts.show', $post)" :title="$post->name" :description="$post->intro" :image="$post->featured_image_url" :hashtags="['laravel', 'sharing']" :networks="['x', 'facebook', 'linkedin', 'copy', 'native']" />
Tailwind Example
<x-sharekit::buttons theme="tailwind" :url="route('posts.show', $post)" :title="$post->name" :description="$post->intro" :image="$post->featured_image_url" :networks="['x', 'facebook', 'linkedin', 'copy', 'native']" />
Available Props
<x-sharekit::buttons /> supports these main props:
urltitletextdescriptionimageviahashtagsnetworksthemelabelshow-labelsshow-headingsizepopupnative
Supported Networks
By default the package supports:
xfacebooklinkedinwhatsapptelegramredditemailcopynative
You can change the defaults in the config file or pass :networks="[...]" directly in the component.
Metadata Resolution
Sharekit resolves metadata in this order:
- Props passed directly to the component
- Page metadata detected in the browser from Open Graph, Twitter, canonical, and standard meta tags
- Server-side fallback values such as current URL and app name
This lets you drop the component into a page with good meta tags and get sensible share output with minimal configuration.
Themes
The package currently includes:
defaulttailwind
Theme mappings live in config/sharekit.php, so you can adjust classes or add future themes later without changing the package API.
Configuration
The config file includes options for:
- default theme
- Blade stack names
- popup dimensions
- whether native sharing is enabled when available
- default enabled networks
- label text
- theme class maps
Example:
'stack_names' => [ 'styles' => 'after-styles', 'scripts' => 'after-scripts', ],
Working With Laravel Cube
Laravel Sharekit works nicely with nasirkhan/laravel-cube.
A typical pattern is:
- use Cube for shared UI, layout, forms, navigation, and base frontend components
- use Sharekit only on content-detail pages such as posts, news items, events, or products
Example:
<x-cube::header-block :title="$post->name" /> <x-sharekit::buttons theme="tailwind" :url="route('posts.show', $post)" :title="$post->name" :description="$post->intro" :image="$post->featured_image_url" />
Testing
vendor/bin/phpunit
Suggested GitHub Topics
You can use these as GitHub repository topics/tags:
- laravel
- php
- blade-components
- social-share
- share-buttons
- sharing
- laravel-package
- reusable-components
- frontend
- web-share-api
- tailwindcss
- bootstrap
Composer Keywords Suggestion
Suggested package keywords:
- laravel
- sharing
- social-share
- social-sharing
- blade-components
- share-buttons
- share-links
- sharekit
- web-share-api
- frontend
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Contributions, feedback, and suggestions are welcome.
Security
If you discover any security related issues, please email nasir8891@gmail.com instead of using the issue tracker.
Credits
License
The GNU General Public License v3.0 or later. Please see LICENSE for more information.