Socket
Socket
Sign inDemoInstall

@greatsumini/react-facebook-login

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@greatsumini/react-facebook-login

Well-typed React Component for Facebook Login


Version published
Weekly downloads
13K
decreased by-16.32%
Maintainers
1
Weekly downloads
 
Created
Source

React Facebook Login

NPM version NPM downloads NPM bundle size CI CD GitHub Stars


React Component for Facebook Login. aims to improve react-facebook-login.
한글 가이드

  • 💙 Typescript support
  • 📦 6kb mini library
  • 👫 All browsers supported
  • 🏃 Currently maintaining

Table of contents

Getting Started

npm i --save @greatsumini/react-facebook-login
# or
yarn add @greatsumini/react-facebook-login

Usage

Component

import FacebookLogin from '@greatsumini/react-facebook-login';

// default
<FacebookLogin
  appId="1088597931155576"
  onSuccess={(response) => {
    console.log('Login Success!', response);
  }}
  onFail={(error) => {
    console.log('Login Failed!', error);
  }}
  onProfileSuccess={(response) => {
    console.log('Get Profile Success!', response);
  }}
/>

// custom style
<FacebookLogin
  appId="1088597931155576"
  style={{
    backgroundColor: '#4267b2',
    color: '#fff',
    fontSize: '16px',
    padding: '12px 24px',
    border: 'none',
    borderRadius: '4px',
  }}
/>

// custom render function
<FacebookLogin
  appId="1088597931155576"
  onSuccess={(response) => {
    console.log('Login Success!', response);
  }}
  onFail={(error) => {
    console.log('Login Failed!', error);
  }}
  onProfileSuccess={(response) => {
    console.log('Get Profile Success!', response);
  }}
  render={({ onClick, logout }) => (
    <CustomComponent onClick={onClick} onLogoutClick={logout} />
  )}
/>

// custom params, options
<FacebookLogin
  appId="1088597931155576"
  useRedirect
  initParams={{
    version: 'v10.0',
    xfbml: true,
  }}
  dialogParams={{
    response_type: 'token',
  }}
  loginOptions={{
    return_scopes: true,
  }}
/>

FacebookLoginClient

You can manually call facebook sdk related functions with FacebookLoginClient

import { FacebookLoginClient } from '@greatsumini/react-facebook-login';

FacebookLoginClient.getLoginStatus((res) => {
  console.log(res.status);
});

FacebookLoginClient.login((res) => {
  console.log(res);
});

FacebookLoginClient.getProfile((res) => {
  console.log(res.id, res.name, res.email);
});

FacebookLoginClient.logout(() => {
  console.log('logout completed!');
});

Examples

You can checkout examples here

Props

Check all available params,options here

PropertyDescriptionTypeDefault
appId *Your application ID.string-
languageAPI versionstring'en_US'
scopeComma seperated list of permissions for login.string'public_profile, email'
fieldsfields return by /me (profile)string'name,email,picture'
onSuccessfunction-
onFailfunction-
onProfileSuccessfunction-
stylecss properties for login buttonCSSProperties-
childrenChildren ComponentReactNode | ReactNodeArray"Login with Facebook"
renderCallback which render custom componentfunction-
autoLoadif true, request login on mountbooleanfalse
useRedirectif true, use redirect instead of window.FB.loginbooleanfalse (forced to be true in fb browers (ref))
useCustomChatif true, append 'xfbml.customerchat' to sdk urlbooleanfalse
initParamsparams for FB.initInitParamsdocs
dialogParamsparams for login dialogDialogParamsdocs
loginOptionsoptions for FB.loginLoginOptionsdocs

Stay in touch

License

React Facebook Login is MIT licensed.

Keywords

FAQs

Package last updated on 03 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc