The SDK is available in two formats and has a number of options for maximum compatibility with any application and branding needs.

There is no tradeoff in functionality between the CDN or the npm SDK sources. It’s merely a difference in packaging. However, if you want maximum customizability, you should lean towards the npm package since the CDN (“web”) SDK includes some done-for-you behaviors that cannot be disabled.

Source: CDN

The SDK is available at and can be sourced by a simple <script> tag. It’s recommended that you use the async or defer attributes to optimize your page load.

<script async src=""></script>

When loaded, the btnsocial global object is available. All methods described are available on this namespace.

Unlike the npm package, the web SDK immediately invokes listen() to begin intercepting links to the all <a> links that start with the "" URL prefix.


The web SDK is configured through HTML attributes on the <script> element.


Type: "redirect" | "popup"
Default: "redirect"

The type of OAuth flow to initiate.


Type: number
Default: 500

NOTE: Option only applies when data-mode="popup" is in use.

The width, in pixels, for the "popup" dialog.


Type: number
Default: 600

NOTE: Option only applies when data-mode="popup" is in use.

The height, in pixels, for the "popup" dialog.


Type: string
Default: undefined

The name of the function to invoke when the SDK is ready.
Important: The function must be available in the global scope.

This option provides a safe way to interact with the btnsocial global. It guarantees that the btnsocial namespace is defined and available for your callback to use.


<script async data-jsonp="myCallback" src=""></script>
<script defer>
  // Global function that the SDK will call
  // automatically once it has downloaded
  function myCallback() {
    // Guarantees that the `btnsocial` object is defined
    btnsocial.onlogin(function (payload) {
      console.log('login complete!', payload);

Source: npm

The "" package is available on the npm registry:

$ npm install

While intended for use within single-page applications (SPAs), any application may use the npm package.

You may then use it anywhere within your application:

import * as btn from '';


Important: When using the npm package, you must call onlogin() before you invoke listen() – if at all.

import * as btn from '';

btn.onlogin(function (payload) {
  console.log('login complete!', payload);

// Listen to all links matching:
//~> 'a[href^=""]'
let unlisten = btn.listen({
  // Open links in "popup" mode
  redirect: false,

// Some time later...
// Detach a[href^="..."] listener


The SDK’s shared interfaces.
All snippets are represented as TypeScript definitions.


The response payload object for successful logins.

type Payload<U={}> = {
  network: string; // The network provider used
  user?: U; // The user's provider profile; if configured
  token?: string; // The user's provider token; if configured
  type?: string; // The token type; if `token` is configured


The popup dialog’s configuration values.

type Options = {
   * The desired width of the popup window.
   * @default 500
  width?: number;
   * The desired height of the popup window.
   * @default 600
  height?: number;
   * The popup window's target name. Supports special `target=""` values.
   * @example "_self", "_blank", ""
   * @default ""
  name?: string;


A returned function that you can call to detach or reset an action.

type Unsubscribe = () => void;



Retrieve the most recent Payload, if any.

Ideal for use alongside redirect() usage to obtain the post-waterfall result.

declare function last(): Payload | undefined;


Initiate a login attempt with a popup window.

declare function popup(
  appid: string, // the Application ID
  network: string, // the lowercased OAuth provider name; eg "github" or "google"
  options?: Options, // custom dialog configuration, if any
): Promise<Payload>;


Initiate a login attempt with a redirect sequence.

declare function redirect(
  appid: string, // the Application ID
  network: string // the lowercased OAuth provider name; eg "github" or "google"
): void;


Important: When using the npm package, you must use onlogin() before listen() is called.

Define a Callback that will run when the user successfully logs in.

Returns an Unsubscribe handler, which will deactivate the Callback provided.

You may have more than one Callback active at a time.

type Callback = (payload: Payload) => any;
declare function onlogin(callback: Callback): Unsubscribe;


Note: This method is only available within the npm package!
Important: Unlike the web SDK, the npm package uses popups by default.

Programmatically attach an event listener to all links that match the selector a[href^=""] at the time of invocation.

Returns an Unsubscribe handler, which you may use to detach all listeners that listen() created.

Ideal for single-page applications (SPAs), where chunks of content swap in and out often.

declare function listen(options?: Options & {
   * Use redirects instead of popup dialogs
   * @default false
  redirect?: boolean;
}): Unsubscribe;