Laravel Add Share Social Media Button Example Tutorial

Jun 25, 2021 . Admin

Hello Friends,

Now let's see example of how to add share social media button in laravel. This is a short guide on laravel if add share social media button. We will use how to use add share social media button in laravel. Here you will learn how to use add share social media button in laravel. Let's get started with how to add share social media button in laravel.

Here i will give you many example how you can add share social media button in laravel.

Step 1 : Install Laravel 8

we need to get fresh laravel 8 version application So let's open terminal and run bellow command to install fresh laravel project.

composer create-project --prefer-dist laravel/laravel blog
Step 2 : Install "jorenvanhocht/laravel-share" Package

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

composer require jorenvanhocht/laravel-share

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

Path: config/app.php

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

After 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

We need to add route for share social in laravel application.

Path: routes\web.php

    use App\Http\Controllers\ShareSocialLinkController;

    | Web Routes
    | Here is where you can register web routes for your application. These
    | routes are loaded by the RouteServiceProvider within a group which
    | contains the "web" middleware group. Now create something great!

        Route::get('/share-social-link', [ShareSocialLinkController::class,'shareSocialLink']);
Step 4 : Create Controller

Here this step now we should create new controller as ShareSocialLinkController.

php artisan make:controller ShareSocialLinkController

Path: app/http/controller/ShareSocialLinkController.php


namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

class ShareSocialLinkController extends Controller
    public function shareSocialLink()
        $socialShareLink = \Share::page(
            'Laravel Custom Foreign Key Name Example',
        return view('share-social-link', compact('socialShareLink'));
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:

Path: /resources/views/share-social-link.blade.php

<!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;
    <body class="bg-dark">
        <div class="row mt-5">
            <div class="col-md-6 offset-3">
                <div class="card">
                    <div class="card-header">
                        <h5>How to Add Share Social Media Button in Laravel -</h5>
                    <div class="card-body">
                        <strong class="float-left pt-2">Social Media : </strong>
                        {!! $socialShareLink !!}

Now run bellow command for quick run:

php artisan serve

Now open bellow URL on your browser:


It will help you....