A simple and easy-to-use social share tool.
Switch branches/tags
Nothing to show
Latest commit 515fea3 Feb 19, 2013 @popomore popomore fix homepage link
Failed to load latest commit information.
assets support browser tests Nov 4, 2012
examples support browser tests Nov 4, 2012
src set data-shareurl Nov 5, 2012
tests add more testcase Nov 5, 2012
.gitignore add gitignore Nov 3, 2012
.travis.yml change test Nov 5, 2012
MIT-license.txt 初始化服务 Apr 15, 2012
Makefile change to uglifyjs #3 Jan 14, 2013
README.md update doc Jan 14, 2013
component.json support bower Feb 19, 2013
package.json fix homepage link Feb 19, 2013
share.js edit makefile Nov 3, 2012
share.min.js change to uglifyjs #3 Jan 14, 2013


Social Share Build Status

A simple and easy-to-use social share tool. It can be used in both browser and nodejs.

First of all, view the example.

How to use


<script src="share.min.js"></script>
<a data-service="twitter">twitter</a>
<a data-service="facebook">facebook</a>


var list = document.getElementsByTagName('a');
Share.init(list, {
    title: 'share it',
    url: 'https://github.com/popomore/social-share'

Find the DOM and bind event, popup the window and redirect to the service when DOM is clicked.

data-service must be specified. See Support service


<a data-service="twitter" data-title="share twitter">twitter</a>

DATA-API is higher priority than options, then the share content will be "share twitter".


  • title - share content
  • url - share url
  • pic - share picture

However, not all of the services support these parameter, view the defference.

Support service

Icon Service website
sina http://weibo.com/
douban http://www.douban.com/
kaixin http://www.kaixin001.com/
netease http://t.163.com/
qq_t http://t.qq.com/
qq_zone http://qzone.qq.com/
renren http://renren.com/
sohu http://t.sohu.com/
facebook http://www.facebook.com/
twitter http://twitter.com/

The difference between services

Add new service

Edit src/parser.js, and add service url which just support three parameter(title, url, pic).

jQuery support

If you use jQuery, it's easy to use.

    title:'share it'

jQuery Example

Node.js support

Install social-share by npm

$ npm install social-share

Just use it

var share = require('social-share');
var url = share('twitter', {
    title:'share it'

If you use express, you can

app.get('/redirect', function(req, res) {
    var url = share(req.query.service, req.query);

You can clone the repo to view the example.

$ git clone https://github.com/popomore/social-share.git
$ make server