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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@lcbase/social-login

v0.5.1

Published

This package is used to handle `Oauth 2.0` login with social network services from client side using `javascript` or `typescript`.

Downloads

6

Readme

social-login

This package is used to handle Oauth 2.0 login with social network services from client side using javascript or typescript.

It can be used for any front-end framework like Vanilla, React, Angular, Vue, Lit, Svelte...etc.

Get Started

  1. Installation
# with pnpm
pnpm add @lcbase/social-login

# with npm
npm i @lcbase/social-login

# with yarn
yarn add @lcbase/social-login
  1. Import and configure component.
<button id="google" part="button">Login with google</button>
<button id="microsoft" part="button">Login with microsoft</button>
<button id="facebook" part="button">Login with facebook</button>
<button id="twitter" part="button">Login with twitter</button>
<button id="naver" part="button">Login with naver</button>
<button id="kakao" part="button">Login with kakao</button>
<button id="tiktok" part="button">Login with tiktok</button>

<script type="module">
  import {
    facebookLoginPopup,
    googleLoginPopup,
    kakaoLoginPopup,
    microsoftLoginPopup,
    naverLoginPopup,
    socialLoginCleanup,
    socialLoginInit,
    tiktokLoginPopup,
    twitterLoginPopup,
  } from '@lcbase/social-login';

  socialLoginInit({
    onSuccess(data) {
      console.log(data);
    },
    onError(error) {
      console.error(error);
    },
  });

  document.getElementById("google").addEventListener("click", () => {
    googleLoginPopup({
      client_id: 'your_google_client_id',
    });
  }, false);

  document.getElementById("microsoft").addEventListener("click", () => {
    microsoftLoginPopup({
        client_id: 'your_microsoft_client_id',
      }).catch(err => console.error(err));
  }, false);
  ...
</script>

How to use

Note:

  • Only support Authorization Code Flow to get auth code and you need a your back-end api to exchange code to access_token.
  • Only support Login with Popup to improve UX.
  • Currently supports Facebook, Google, Twitter, Microsoft, Tiktok, Kakao, naver as providers (more to come!).
  1. Social Login Initialize
  • Initialize only once in your app and get data from all providers.
import { socialLoginInit } from '@lcbase/social-login';

socialLoginInit({
  onSuccess(data) {
    console.log(data);
  },
  onError(error) {
    console.error(error);
  },
});

Note: If your redirect_url is not the same as the URL where socialLoginInit is located. Please add authCallbackHandler function to your redirect url page.

eg: In /auth/callback page

import { authCallbackHandler } from '@lcbase/social-login';

authCallbackHandler();
  1. Google Login
  • Google Parameters here.
import { googleLoginPopup } from '@lcbase/social-login';

googleLoginPopup(params);
  1. Microsoft Login
  • Microsoft Parameters here.
import { microsoftLoginPopup } from '@lcbase/social-login';

microsoftLoginPopup(params);
  1. Facebook Login
  • Facebook Parameters here.
import { facebookLoginPopup } from '@lcbase/social-login';

facebookLoginPopup(params);
  1. Twitter Login
  • Twitter Parameters here.
import { twitterLoginPopup } from '@lcbase/social-login';

twitterLoginPopup(params);
  1. Kakao Login
  • Kakao Parameters here.
import { kakaoLoginPopup } from '@lcbase/social-login';

kakaoLoginPopup(params);
  1. Naver Login
  • Naver Parameters here.
import { naverLoginPopup } from '@lcbase/social-login';

naverLoginPopup(params);
  1. Tiktok Login
  • Tiktok Parameters here.
import { tiktokLoginPopup } from '@lcbase/social-login';

tiktokLoginPopup(params);

📝 License

MIT