Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Port of Facebook's php sdk
Branch: master

Merge pull request #2 from 8bitDesigner/patch-1

Added connect to dependencies
latest commit 0b485b7c4b
@tenorviol authored

node.js Facebook SDK

This is a complete port of Facebook's PHP SDK library.

The Facebook Platform is a set of APIs that make your application more social. Read more about integrating Facebook with your web site on the Facebook developer site.

The node.js Facebook SDK is licensed under the Apache License, Version 2.0, as was the original library.


npm install facebook-sdk

Use as connect middleware

The following will attach a new Facebook object to each incoming http request. For more information on querying Facebook's graph api, see

var connect = require('connect'),
  fbsdk = require('facebook-sdk');

    appId  : 'YOUR APP ID',
    secret : 'YOUR API SECRET'
  .use(function(req, res, next) {

    if (req.facebook.getSession()) {
      res.end('<a href="' + req.facebook.getLogoutUrl() + '">Logout</a>');

      // get my graph api information
      req.facebook.api('/me', function(me) {

    } else {
        res.end('<a href="' + req.facebook.getLoginUrl() + '">Login</a>');


Stand alone usage

var fbsdk = require('facebook-sdk');

var facebook = new fbsdk.Facebook({
  appId  : 'YOUR APP ID',
  secret : 'YOUR API SECRET'

facebook.api('/YOUR APP ID', function(data) {


The tests have been ported to run using nodeunit. This was the easiest way to confirm the new node.js library works as expected. Some new tests have been added to cover edge cases, and others not relevant in the new environment have been removed.

Something went wrong with that request. Please try again.