项目
在 GitHub 查看
greatSumini/react-facebook-login
关于
Well-Typed React Component for Facebook Login
网站与应用开发实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 正在收集历史
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文React Facebook Login
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
🚨 Common Issue - "Sorry, something went wrong"
Facebook requires apps in development to add users explicitly as testers.
Please add app test users under the "App Roles" section. the you can login as one of the added test users.
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
| Property | Description | Type | Default |
|---|---|---|---|
| appId * | Your application ID. | string | - |
| language | API version | string | 'en_US' |
| scope | Comma seperated list of permissions for login. | string | 'public_profile, email' |
| fields | fields return by /me (profile) | string | 'name,email,picture' |
| onSuccess | function | - | |
| onFail | function | - | |
| onProfileSuccess | function | - | |
| style | css properties for login button | CSSProperties | - |
| children | Children Component | ReactNode | ReactNodeArray | "Login with Facebook" |
| render | Callback which render custom component | function | - |
| autoLoad | if true, request login on mount | boolean | false |
| useRedirect | if true, use redirect instead of window.FB.login | boolean | false (forced to be true in fb browers (ref)) |
| useCustomChat | if true, append 'xfbml.customerchat' to sdk url | boolean | false |
| initParams | params for FB.init | InitParams | docs |
| dialogParams | params for login dialog | DialogParams | docs |
| loginOptions | options for FB.login | LoginOptions | docs |
Stay in touch
- Author - Sumin Choi
License
React Facebook Login is MIT licensed.
Links
探索相关项目
加载中…