arrow_back
Back

Facebook Login: JavaScript SDK, App ID, and Quickstart

Andrew Dorokhov Andrew Dorokhov schedule 1 min read
menu_book Table of Contents

Official docs:

Testing

Loading the JavaScript SDK

<script>
  window.fbAsyncInit = function() {
    FB.init({
      appId            : 'your-app-id',
      xfbml            : true,
      version          : 'v3.2'
    });
  };
</script>
<script async defer src="https://connect.facebook.net/en_US/sdk.js"></script>

appId is the application ID from the open_in_new App Dashboard .

If you prefer to keep the loader in one place (including the async script injection):

<script>
  window.fbAsyncInit = function() {
    FB.init({
      appId      : '{your-app-id}',
      cookie     : true,
      xfbml      : true,
      version    : '{api-version}'
    });

    FB.AppEvents.logPageView();
  };

  (function(d, s, id){
     var js, fjs = d.getElementsByTagName(s)[0];
     if (d.getElementById(id)) {return;}
     js = d.createElement(s); js.id = id;
     js.src = "https://connect.facebook.net/en_US/sdk.js";
     fjs.parentNode.insertBefore(js, fjs);
   }(document, 'script', 'facebook-jssdk'));
</script>

Language for social plugins

Change the locale in the SDK URL, for example:

<script async defer src="https://connect.facebook.net/es_LA/sdk.js"></script>

Setup checklist

  1. Create an App ID.
  2. Enable the Facebook Login product for the app.
  3. Use the Facebook Login Quickstart to fill in the required parameters quickly.
code

Need Help with Development?

Happy to help — reach out via the contacts or go straight to my Upwork profile.

work View Upwork Profile arrow_forward