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

@vitra-ai/nextjs-auth

v0.9.0

Published

Next.js authentication library built with better-auth for Vitra AI

Readme

@vitra-ai/nextjs-auth

A comprehensive Next.js authentication library built on top of Better Auth, providing a complete authentication solution with pre-built UI components, hooks, and utilities.

Features

  • 🔐 Complete Auth Solution - Pre-built authentication flows with customizable UI
  • 🎨 Beautiful UI Components - Modern, accessible components built with Radix UI
  • 🔌 Plugin System - Flexible configuration for all Better Auth plugins
  • 🏢 Organization Management - Multi-tenant support with roles and permissions
  • 📱 Multiple Auth Methods - Email OTP, Magic Links, OAuth, Passkeys, and more
  • 🎯 Type-Safe - Full TypeScript support with IntelliSense
  • 🌍 Internationalization - Built-in localization support
  • Server & Client - Server-side and client-side authentication utilities

Installation

npm install @vitra-ai/nextjs-auth better-auth
# or
bun install @vitra-ai/nextjs-auth better-auth

Quick Start

1. Create Auth Client

Create your authentication client with the plugins you need:

// lib/auth-client.ts
import { createAuthClient } from "@vitra-ai/nextjs-auth";

export const authClient = createAuthClient({
  baseURL: process.env.NEXT_PUBLIC_API_URL,
  plugins: {
    emailOTP: { enabled: true },
    organization: {
      enabled: true,
      // dynamicAccessControl and description field are included by default
    },
  },
});

See CREATE_AUTH_CLIENT.md for full documentation.

2. Wrap Your App

// app/layout.tsx
import { AuthUIProvider } from '@vitra-ai/nextjs-auth';
import { authClient } from '@/lib/auth-client';
import '@vitra-ai/nextjs-auth/css';

export default function RootLayout({ children }) {
  return (
    <html>
      <body>
        <AuthUIProvider authClient={authClient}>
          {children}
        </AuthUIProvider>
      </body>
    </html>
  );
}

3. Use Auth Components

// app/page.tsx
import { AuthView, SignedIn, SignedOut } from '@vitra-ai/nextjs-auth';

export default function Page() {
  return (
    <>
      <SignedOut>
        <AuthView />
      </SignedOut>
      <SignedIn>
        <h1>Welcome! You're signed in.</h1>
      </SignedIn>
    </>
  );
}

Core Features

Authentication Client

The createAuthClient function provides a type-safe, flexible way to configure your authentication:

import { createAuthClient } from "@vitra-ai/nextjs-auth";

export const authClient = createAuthClient({
  baseURL: process.env.NEXT_PUBLIC_API_URL,
  plugins: {
    emailOTP: { enabled: true },
    organization: { enabled: true },
    twoFactor: { enabled: true },
    passkey: { enabled: true },
  },
  additionalPlugins: [
    // Add custom plugins here
  ],
});

📖 Full Documentation

UI Components

Pre-built, customizable components for common authentication flows:

  • <AuthView /> - Complete authentication flow
  • <SignedIn> / <SignedOut> - Conditional rendering
  • <OrganizationSwitcher /> - Multi-tenant organization selector
  • Settings views for profile, security, organizations, and more

Hooks

Powerful hooks for authentication state and actions:

import { useAuthData, useCurrentOrganization } from '@vitra-ai/nextjs-auth/hooks';

function MyComponent() {
  const { user, session } = useAuthData();
  const { organization } = useCurrentOrganization();

  return <div>Welcome, {user?.name}</div>;
}

Server Utilities

Server-side authentication helpers (coming soon):

import { getSession } from "@vitra-ai/nextjs-auth/server";

export async function GET() {
  const session = await getSession();
  if (!session) {
    return new Response("Unauthorized", { status: 401 });
  }
  // ...
}

Documentation

Available Plugins

The library supports all Better Auth plugins with easy configuration:

  • ✉️ Email OTP - Passwordless authentication with email codes
  • 🏢 Organization - Multi-tenant support with roles and permissions
  • 🔑 Passkey - WebAuthn/Passkey authentication
  • 🔐 Two-Factor - TOTP-based 2FA
  • Magic Link - Passwordless authentication via email links
  • 👥 Multi-Session - Support for multiple concurrent sessions
  • 🔧 API Key - API key authentication
  • 👤 Anonymous - Anonymous user sessions
  • 📝 Username - Username-based authentication
  • 🌐 Generic OAuth - Custom OAuth providers
  • 🔵 One Tap - Google One Tap sign-in

Exports

The package provides multiple export paths for different use cases:

// Main exports - Components, hooks, types
import { AuthView, useAuthData } from "@vitra-ai/nextjs-auth";

// Hooks only
import { useAuthData } from "@vitra-ai/nextjs-auth/hooks";

// Server utilities
import { getSession } from "@vitra-ai/nextjs-auth/server";

// Form components
import { LoginForm } from "@vitra-ai/nextjs-auth/forms";

// Extra utilities
import { Toaster } from "@vitra-ai/nextjs-auth/goodies";

// Styles
import "@vitra-ai/nextjs-auth/css";

Development

# Install dependencies
bun install

# Build the package
bun run build

# Watch mode for development
bun run dev

Contributing

This package is part of the Vitra AI monorepo. For contributions, please follow the monorepo guidelines.

License

Proprietary - Vitra AI

Author

Shikhar Singh [email protected]

Links