How To Add Share Social Media Button In Laravel?




How To Add Share Social Media Button In Laravel?

Hello Friends,

In this tutorial, i would like share with you how to integrate share social media button in laravel application. We will show laravel share post on social media example. This article will give you example of how to share social media links in laravel.

If you want to share your post in social media using social button then you can use bellow example. Here i will give simple example of how to add social media share buttons on website in laravel.

Here i will give full example for laravel share post on facebook, twitter, whatsapp etc. you can also use this example with laravel 6, laravel 7 and laravel 8 version. So let's see the bellow example step by step.

Step 1: Install Laravel Project

First, you need to download the laravel fresh setup. Use this command then download laravel project setup :

composer create-project --prefer-dist laravel/laravel blog

Step 2 : Install "jorenvanhocht/laravel-share" Package

In this step, You have to need jorenvanhocht/laravel-share package. So let's open terminal and run bellow composer command:

composer require jorenvanhocht/laravel-share

Run succefully above command then after open config/app.php and put the bellow code.


'aliases' => [

'Share' => Jorenvh\Share\ShareFacade::class,


Now publish config file using bellow command so lets open terminal and run bellow command:

php artisan vendor:publish --provider="Jorenvh\Share\Providers\ShareServiceProvider"

Step 3 : Add Route

now, we need to add route for share social in laravel application. so open your "routes/web.php" file and add following route.


use App\Http\Controllers\ShareSocialController;

Route::get('/share-social', [ShareSocialController::class,'shareSocial']);

Step 4 : Create Controller

Here this step now we should create new controller as ShareSocialController. So run bellow command and create new controller.

php artisan make:controller ShareSocialController



namespace App\Http\Controllers;

use Illuminate\Http\Request;

use Illuminate\Support\Facades\Route;

class ShareSocialController extends Controller


public function shareSocial()


$socialShare = \Share::page(


'Laravel Custom Foreign Key Name Example',








return view('share-social', compact('socialShare'));



Step 5 : Create Blade File

In last step. we have to create blade file for list of social button. So finally you have to create following file and put bellow code:


<!DOCTYPE html>



<title>How to Add Share Social Media Button in Laravel -</title>

<link rel="stylesheet" href="" integrity="sha512-iBBXm8fW90+nuLcSKlbmrPcLa0OT92xO1BIsZ+ywDWZCvqsWgccV3gFoRBv0z+8dLJgyAHIhR35VZc2oM/gI1w==" crossorigin="anonymous" referrerpolicy="no-referrer" />

<script src="" integrity="sha512-XKa9Hemdy1Ui3KSGgJdgMyYlUg1gM+QhL6cnlyTe2qzMCYm4nAZ1PsVerQzTTXzonUR+dmswHqgJPuwCq1MaAg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

<link rel="stylesheet" href="" integrity="sha512-P5MgMn1jBN01asBgU0z60Qk4QxiXo86+wlFahKrsQf37c9cro517WzVSPPV1tDKzhku2iJ2FVgL67wG03SGnNA==" crossorigin="anonymous" referrerpolicy="no-referrer" />

<style type="text/css">


list-style: none;

background: #e2e2e2;

margin-left: 5px;

text-align: center;



li span{

font-size: 20px;


ul li{

display: inline-block;

padding: 10px 10px 5px;



float: left;





<div class="row mt-5">

<div class="col-md-6 offset-3">

<div class="card">

<div class="card-header bg-info text-white">

<h5>How to Add Share Social Media Button in Laravel -</h5>


<div class="card-body">

<strong class="float-left pt-2">Social Media : </strong>

{!! $socialShare !!}







Now we are ready to run our example so run bellow command for quick run:

php artisan serve

Now you can open bellow URL on your browser:


It will help you...

#Laravel 8

#Laravel 7


#Laravel 6