Laravel Vue Socialite

Laravel Vue Socialite

Laravel Vue Socialite is a package that integrates Laravel, Vue.js, and Socialite to provide social authentication capabilities in your Laravel and Vue.js applications.


To install Laravel Vue Socialite, follow these steps:

  1. Require the package via Composer:
  2. composer require overtrue/laravel-socialite
  3. Add the Socialite service provider in the providers array of your config/app.php file:
  4. 'providers' => [
        // Other service providers...
  5. Run the migration to create the socialite tables:
  6. php artisan migrate


Here’s an example of how you can use Laravel Vue Socialite:

Backend (Laravel)

In your Laravel application, you first need to configure the socialite providers. This can be done in the config/services.php file:

'github' => [
    'client_id' => env('GITHUB_CLIENT_ID'),
    'client_secret' => env('GITHUB_CLIENT_SECRET'),
    'redirect' => env('GITHUB_REDIRECT_URL')

Next, you can create a route for the authentication process:

Route::get('/auth/{provider}', 'Auth\SocialAuthenticationController@redirectToProvider');

And a callback route to handle the response:

Route::get('/auth/{provider}/callback', 'Auth\SocialAuthenticationController@handleProviderCallback');

Finally, you need to create the controller methods to handle the authentication process:

public function redirectToProvider($provider)
    return Socialite::driver($provider)->redirect();

public function handleProviderCallback($provider)
    $user = Socialite::driver($provider)->user();
    // Process the authenticated user
    // Redirect or do whatever you need

Frontend (Vue.js)

In your Vue.js application, you can use Laravel Vue Socialite to authenticate users via social providers. Here’s an example of how to use the axios library to make a request to the Laravel backend:

let socialLogin = provider => {
    .then(response => {
      // Redirect or do whatever you need
    .catch(error => {
      // Handle error


Laravel Vue Socialite provides a convenient way to implement social authentication in your Laravel and Vue.js applications. By following the installation and usage steps outlined above, you can easily integrate social login functionality into your project.

Read more

Leave a comment