npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@arikajs/socialite

v0.10.7

Published

Modern OAuth authentication for ArikaJS applications.

Readme

@arikajs/socialite

Modern, Fluent, and Scalable Social Authentication for ArikaJS

npm version License: MIT


🚀 Purpose

@arikajs/socialite provides a fluent, expressive interface to OAuth authentication with various social providers. It abstracts the complex OAuth 2.0 flow into a simple, unified API, allowing you to integrate social logins (like Google, GitHub, or Facebook) into your ArikaJS application in minutes.

Instead of writing custom logic for every provider, @arikajs/socialite offers a consistent way to redirect users and retrieve their profiles, handling token exchanges and state validation automatically.

🏗️ Why we are developing this?

Modern web applications are expected to offer seamless login experiences. Manually implementing OAuth for multiple providers is:

  1. Repetitive: The flow is similar but the endpoints and data structures differ.
  2. Error-Prone: Handling state (CSRF protection) and token refreshes manually often leads to security vulnerabilities.
  3. High Maintenance: API changes from providers (like Facebook or Google) require updating your implementation constantly.

@arikajs/socialite solves this by providing a high-level driver-based system that keeps your code clean and your authentication secure.


✨ Feature Highlights

  • 🎯 Fluent API - One line of code to redirect, one line to get the user.
  • 🔐 Built-in CSRF Protection - Automatic state validation for all OAuth redirects.
  • 📦 Multi-Driver Architecture - Easily switch between Google, GitHub, Facebook, etc.
  • 📡 Stateless Mode - Support for API-only applications and SPAs.
  • 🛠️ Unified User Data - Normalizes user profiles across all platforms.
  • 🧪 Test Friendly - Easily mock social logins during development and testing.

🚀 Installation

You can install the package via npm:

npm install @arikajs/socialite

Once installed, you can quickly scaffold the configuration and environment variables using the Arika CLI:

node arika socialite:install

Manual Configuration

If you prefer to configure it manually, publish the configuration file to config/socialite.ts:

export default {
    /**
     * The default socialite driver to use.
     */
    default: 'github',

    /**
     * Socialite Providers Configuration
     */
    providers: {
        github: {
            client_id: process.env.GITHUB_CLIENT_ID,
            client_secret: process.env.GITHUB_CLIENT_SECRET,
            redirect: `${process.env.APP_URL}/auth/github/callback`,
        },

        google: {
            client_id: process.env.GOOGLE_CLIENT_ID,
            client_secret: process.env.GOOGLE_CLIENT_SECRET,
            redirect: `${process.env.APP_URL}/auth/google/callback`,
            // Optional: specify additional scopes
            scopes: ['https://www.googleapis.com/auth/calendar.readonly'],
        },
    },
};

Add your credentials to your .env file:

GITHUB_CLIENT_ID=your_id
GITHUB_CLIENT_SECRET=your_secret

GOOGLE_CLIENT_ID=your_id
GOOGLE_CLIENT_SECRET=your_secret

📚 Basic Usage

1. Redirecting to the Provider

In your controller, simply return the redirect for your chosen provider:

import { Socialite } from '@arikajs/socialite';

export class LoginController {
    /**
     * Redirect the user to the GitHub authentication page.
     */
    async redirectToProvider(request, response) {
        return Socialite.driver('github').redirect();
    }
}

2. Handling the Callback

After the user authenticates, they are redirected back to your app. Retrieve their profile like this:

export class LoginController {
    /**
     * Obtain the user information from GitHub.
     */
    async handleProviderCallback(request, response) {
        const socialiteUser = await Socialite.driver('github').user();

        // socialiteUser contains: 
        // id, nickname, name, email, avatar, etc.
        
        // Find or create a user in your local database
        const user = await User.updateOrCreate(
            { email: socialiteUser.email },
            { 
                name: socialiteUser.name,
                github_id: socialiteUser.id,
                avatar: socialiteUser.avatar 
            }
        );

        // Log them in!
        Auth.login(user);

        return response.redirect('/dashboard');
    }
}

Stateless Usage (for APIs)

If you are building an API or a single-page application and don't use sessions:

const user = await Socialite.driver('google').stateless().user();

🛠️ Supported Drivers

The following drivers are part of the core package:

  • Google
  • GitHub
  • Facebook
  • X (formerly Twitter)
  • LinkedIn
  • GitLab
  • Slack

🤝 Community Adapters

Need more? You will be able to easily create your own drivers by extending the AbstractProvider class to support any OAuth 2.0 service.


📝 License

ArikaJS Socialite is open-sourced software licensed under the MIT license.