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

@thrivereflections/realtime-auth-supabase

v0.1.0

Published

Supabase authentication provider for the Thrive Realtime Voice Platform

Downloads

6

Readme

@thrive/realtime-auth-supabase

Supabase authentication provider for the Thrive Realtime Voice Platform.

Overview

This package provides a complete authentication solution using Supabase Auth with multi-provider support (Google, LinkedIn, Facebook, email/password). It includes user synchronization, session management, and client utilities for Next.js applications.

Features

  • Multi-Provider Authentication: Google, LinkedIn, Facebook, and email/password
  • User Synchronization: Automatic sync from Supabase to your database
  • Session Management: JWT tokens with database verification
  • Next.js Integration: Browser, server, and middleware client utilities
  • TypeScript Support: Full type safety and IntelliSense
  • Logging Integration: Built-in observability and debugging

Installation

npm install @thrive/realtime-auth-supabase

Usage

Basic Setup

import { createAuthProvider, createSupabaseClientFactory, createUserSyncService } from "@thrive/realtime-auth-supabase";
import { InjectableConsoleLogger } from "@thrive/realtime-observability";

// Create logger
const logger = new InjectableConsoleLogger();

// Create Supabase client factory
const supabaseFactory = createSupabaseClientFactory({
  supabaseUrl: process.env.NEXT_PUBLIC_SUPABASE_URL!,
  supabaseAnonKey: process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
  logger,
});

// Create auth provider
const authProvider = createAuthProvider({
  supabaseUrl: process.env.NEXT_PUBLIC_SUPABASE_URL!,
  supabaseAnonKey: process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
  logger,
});

// Set up Supabase client
const supabase = supabaseFactory.createBrowserClient();
if (supabase) {
  authProvider.setSupabaseClient(supabase);
}

User Synchronization

import { createUserSyncService } from "@thrive/realtime-auth-supabase";

// Create user sync service with your database store
const userSync = createUserSyncService(yourDatabaseStore, { logger });

// Sync Supabase user to your database
const user = await userSync.syncUserToAppUser(supabaseUser);

Next.js Integration

Browser Client

// lib/supabase/client.ts
import { createSupabaseClientFactory } from "@thrive/realtime-auth-supabase";

const supabaseFactory = createSupabaseClientFactory({
  supabaseUrl: process.env.NEXT_PUBLIC_SUPABASE_URL!,
  supabaseAnonKey: process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
});

export function createClient() {
  return supabaseFactory.createBrowserClient();
}

Server Client

// lib/supabase/server.ts
import { createSupabaseClientFactory } from "@thrive/realtime-auth-supabase";
import { cookies } from "next/headers";

const supabaseFactory = createSupabaseClientFactory({
  supabaseUrl: process.env.NEXT_PUBLIC_SUPABASE_URL!,
  supabaseAnonKey: process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
});

export async function createClient() {
  const cookieStore = await cookies();
  return await supabaseFactory.createServerClient(cookieStore);
}

Middleware Client

// lib/supabase/middleware.ts
import { createSupabaseClientFactory } from "@thrive/realtime-auth-supabase";
import { NextRequest } from "next/server";

const supabaseFactory = createSupabaseClientFactory({
  supabaseUrl: process.env.NEXT_PUBLIC_SUPABASE_URL!,
  supabaseAnonKey: process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
});

export function createClient(request: NextRequest) {
  return supabaseFactory.createMiddlewareClient(request);
}

API Reference

AuthProvider

The main authentication interface with methods for user management and authentication.

interface AuthProvider {
  getCurrentUser(): Promise<User>;
  isAuthenticated(): Promise<boolean>;
  signInWithEmail(email: string, password: string): Promise<{ user: User | null; error: Error | null }>;
  signUp(email: string, password: string): Promise<{ user: User | null; error: Error | null }>;
  signInWithOAuth(provider: "google" | "linkedin" | "facebook"): Promise<void>;
  signOut(): Promise<void>;
}

UserSyncService

Handles synchronization between Supabase users and your database.

interface UserSyncService {
  syncUserToAppUser(supabaseUser: SupabaseUser): Promise<User | null>;
  getUserByAuthId(authUserId: string): Promise<User | null>;
}

SupabaseClientFactory

Creates Supabase clients for different Next.js contexts.

interface SupabaseClientFactory {
  createBrowserClient(): SupabaseClient | null;
  createServerClient(cookies: any): Promise<SupabaseClient>;
  createMiddlewareClient(request: any): { supabase: SupabaseClient; response: any };
}

Configuration

Environment Variables

# Required
NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key

# Optional OAuth providers
SUPABASE_AUTH_GOOGLE_CLIENT_ID=your_google_client_id
SUPABASE_AUTH_GOOGLE_SECRET=your_google_secret
SUPABASE_AUTH_LINKEDIN_CLIENT_ID=your_linkedin_client_id
SUPABASE_AUTH_LINKEDIN_SECRET=your_linkedin_secret
SUPABASE_AUTH_FACEBOOK_CLIENT_ID=your_facebook_client_id
SUPABASE_AUTH_FACEBOOK_SECRET=your_facebook_secret

Error Handling

All methods include comprehensive error handling and logging. Errors are logged with context and returned in a consistent format:

const { user, error } = await authProvider.signInWithEmail(email, password);
if (error) {
  console.error("Sign in failed:", error.message);
  // Handle error
}

Logging

The package integrates with the Thrive Realtime observability system for comprehensive logging and debugging:

import { InjectableConsoleLogger } from "@thrive/realtime-observability";

const logger = new InjectableConsoleLogger("auth-session");
// Pass logger to all factory functions

TypeScript Support

Full TypeScript support with comprehensive type definitions and IntelliSense support.

License

MIT