How do I test the Facebook "Like" button on localhost?

It is possible to test "Like" button on localhost?


Dave's answer is correct, however, I just discovered a workaround: You can make your local machine accessible by using . You'll need to (temporarily) change some URLs used in your app code / html so links point to the temporary domain, but at least facebook can reach your machine.

Not really; facebook has to crawl your site to pull in the title, description, and thumbnail. It can't get to your site if it's on localhost.

It is possible to perform limited testing on the facebook like button on localhost. It renders properly on my machine. The trick is using a live, non-localhost URL on the data-href attribute (I used Google in the sample below):

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

<div class="fb-like" data-href="" data-width="450" data-layout="button_count" data-show-faces="false" data-send="false"></div>

If you're developing the likebutton for, just add in your hosts file:

Hooray, no more 500s.

Need Your Help

Share Component between 2 modules


I'm trying to include a Component in 2 modules (parent and child) but getting various errors in the process