In this article, we will learn how to integrate login with Facebook react js.
– First of all, we have to create a react application.
– Add the below package.
npm i react-facebook-login
– First, we need to log in to our Facebook accounts.
– Go to the below link and go to My Apps.
https://developers.facebook.com/
– And go to the Create App.
– The steps to create an app are shown in the below image.
Step-1 – Select the type of application.
Step 2 – Add the application name and create an application.
– On the home page Application Id will be there as shown in the below image.
– Now open your app.js file and add the below code:
import './App.css'; import ReactFacebookLogin from 'react-facebook-login'; function App() { const responseFacebook = (response) => { alert(`LoginId is: ${response.email}`) } return ( <div className="App" style={{paddingTop:"15px"}}> <ReactFacebookLogin appId="767400647829532" autoLoad={true} fields="name,email" callback={responseFacebook} /> </div> ); } export default App;
Output:-