npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@hamza-bentahar/nuxt-social-logins

v1.3.1

Published

Nuxt plugin to enable client-side social logins

Readme

Nuxt Social Logins

A client-side integration of the Google Sign-In SDK and Facebook Javascript SDK for Nuxt.js.
It allows the user to authenticate with Google or Facebook, and returns the active profile data to the calling application, so it could be handled according to the developer's needs.

Quick Links

  1. Installation
  2. Setup
  3. Configuration
  4. How to use
  5. Components

Install

Install the package:

npm i @hamza-bentahar/nuxt-social-logins

Setup

Add  @hamza-bentahar/nuxt-social-logins under modules in nuxt.config.js

// nuxt.config.js

{
  modules: [
    '@hamza-bentahar/nuxt-social-logins',
  ],
}

Configuration can be passed along with the module declaration:

{
  modules: [
    ['@hamza-bentahar/nuxt-social-logins', {
        // options
    }]
  ],
}

or in a separate socialLogins key:

{
  modules: [
    '@hamza-bentahar/nuxt-social-logins',
  ],
  socialLogins: {
      // options
  }
}

Configuration

By default, all login providers will be disabled unless you pass configuration for them in the module options. If enabled, each provider will register as a separate plugin in the Vue prototype.

Note: Since the plugin is intended to only be used from the client, it isn't available in the context of the application (e.g. in AsyncData())
  • Facebook

To enable facebook authentication, pass the facebook object in the options. This enables the use of this.$fbAuth inside your app

{
	facebook: {
		appId: `YOUR_APP_ID`;
	}
}
  • Google

To enable google authentication and use this.$googleAuth, pass the google object in options. It also enables the usage of GoogleButton component..

{
	google: {
		clientId: `YOUR_CLIENT_ID`;
	}
}

How to use

If $googleAuth and $fbAuth are enabled in the Vue prototype, they both export a set of functions that are wrappers around the SDK functionality. All functions have no parameters and return promises.

The format of the response the promises resolve to is:

Auth response object:

{
    signedIn: boolean,
    userData: {
        id: string,
        firstName: string,
        lastName: string,
        email: string
    }
}

init()

Best used when the page loads, for example in the layout or index page mounted() hook. It checks if the user is currently authenticated, and returns the auth response as an object.

Example:

// index.vue

 async mounted() {
      const res = await this.$googleAuth.init();
      if (res.signedIn) {
        console.log(res.userData.id);
        console.log(res.userData.firstName);
        console.log(res.userData.lastName);
        console.log(res.userData.email);
      }

      // do something with response
  }

signIn()

Attempts to log the user in. Opens a dialog, requesting their confirmation if it hasn't already been granted. Returns the auth response on resolve, or the error on reject.

Example:

// some-component.vue

 async signIn() {
     try {
        const res = await this.$googleAuth.signIn();
        if (res.signedIn) {
            console.log(res.userData.id);
            console.log(res.userData.firstName);
            console.log(res.userData.lastName);
            console.log(res.userData.email);
        }

        // do something with response
    } catch(e) {
        console.log(e);
    }
  }

signOut()

Attemps to log the user out. Returns a success message on resolve, and an the error on reject.

Example:

// some-component.vue

 async signOut() {
     try {
        const res = await this.$googleAuth.signOut();
        console.log(res);
    } catch(e) {
        console.log(e);
    }
  }

Components

The module also includes a couple of premade default button components that can be used for user authentication. They both can receive buttonText and customClass to override the default one as properties.

Style structure:

.custom-class {
    /* custom styles */
}
.custom-class .icon {
    /* custom styles for button icon */
}
.custom-class .title {
    /* custom styles for the button text */
}

GoogleButton:

A default google sign-in button. Fires the $googleAuth.signIn() function on click, and emits the response or error as events.

Example:

<google-button 
    :button-text="'Your custom text'" 
    :custom-class="'custom-class'" 
    @signed-in:"onGoogleSignedIn(res)"
    @signed-in-error: "onGoogleInError(err)"
/>

FacebookButton:

A default facebook sign-in button. Fires the $fbAuth.signIn() function on click, and emits the response or error as events.

Example:

<facebook-button 
    :button-text="'Your custom text'" 
    :custom-class="'custom-class'" 
    @signed-in:"onFacebookSignedIn(res)"
    @signed-in-error: "onFacebookSignInError(err)"
/>