npm package: @qmm1222/universal-auth
Description: Universal authentication solution for Vercel + Supabase projects, based on Better Auth.
Author: QMM1222
Latest version: 1.0.7
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# @qmm1222/universal-auth

Universal authentication solution for Vercel + Supabase projects, based on Better Auth.

[![NPM Version](https://img.shields.io/npm/v/@qmm1222/universal-auth)](https://www.npmjs.com/package/@qmm1222/universal-auth)
[![License](https://img.shields.io/npm/l/@qmm1222/universal-auth)](https://github.com/QMM1222/better-auth-adapted/blob/main/LICENSE)
[![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue)](https://www.typescriptlang.org/)

## ✨ Features

- 🚀 **Universal** - Works seamlessly with Vercel, Supabase, and Next.js
- 🔐 **Secure** - Built on top of Better Auth with modern security practices
- 🎯 **Easy Setup** - Quick start with predefined presets
- 🌐 **Social Auth** - GitHub, Google, and more social providers
- 📱 **Multi-Platform** - React, Vue, Svelte, Solid support
- 🔑 **2FA Ready** - Two-factor authentication support
- 🏢 **Enterprise** - Organization and role-based access control
- 📚 **TypeScript** - Full TypeScript support with type safety

## 🚀 Quick Start

### Installation

```bash
npm install @qmm1222/universal-auth
```

### Basic Setup

```typescript
// lib/auth.ts
import { quickStart } from '@qmm1222/universal-auth';

export const auth = quickStart.standard("my-app");
```

```typescript
// app/api/auth/[...all]/route.ts
import { auth } from '@/lib/auth';
import { toNextJsHandler } from '@qmm1222/universal-auth/next-js';

const handler = toNextJsHandler(auth);
export { handler as GET, handler as POST };
```

```typescript
// lib/auth-client.ts
import { createUniversalAuthClient } from '@qmm1222/universal-auth/client';

export const authClient = createUniversalAuthClient({
  baseURL: process.env.NODE_ENV === 'production' 
    ? 'https://your-domain.com' 
    : 'http://localhost:3000'
});
```

### Social Login

```tsx
'use client';
import { authClient } from '@/lib/auth-client';

export function LoginButton() {
  const handleLogin = async () => {
    await authClient.signIn.social({
      provider: 'github',
      callbackURL: '/dashboard'
    });
  };

  return (
    <button onClick={handleLogin}>
      Sign in with GitHub
    </button>
  );
}
```

## 📦 Available Presets

```typescript
import { createUniversalAuth } from '@qmm1222/universal-auth';

export const auth = createUniversalAuth({
  projectName: "my-app",
  presets: {
    supabase: true,    // Supabase integration
    vercel: true,      // Vercel deployment optimized
    social: true,      // Social login providers
    project: true      // Basic project setup
  }
});
```

## 🔌 Supported Frameworks

- **React** - `@qmm1222/universal-auth/react`
- **Vue** - `@qmm1222/universal-auth/vue`
- **Svelte** - `@qmm1222/universal-auth/svelte`
- **Solid** - `@qmm1222/universal-auth/solid`
- **Next.js** - `@qmm1222/universal-auth/next-js`

## 🗄️ Database Adapters

- **Prisma** - `@qmm1222/universal-auth/adapters/prisma`
- **Drizzle** - `@qmm1222/universal-auth/adapters/drizzle`
- **MongoDB** - `@qmm1222/universal-auth/adapters/mongodb`

## 🔐 Authentication Methods

- Email/Password
- Social providers (GitHub, Google, Discord, etc.)
- Magic links
- Phone number OTP
- Passkeys/WebAuthn
- Anonymous users

## 🛡️ Security Features

- Two-factor authentication
- Session management
- CSRF protection
- Rate limiting
- Password strength validation
- Have I Been Pwned integration

## 🌍 Environment Variables

```bash
# Required
DATABASE_URL=postgresql://user:password@host:5432/database
BETTER_AUTH_SECRET=your_32_character_secret_key_here

# Social providers (optional)
GITHUB_CLIENT_ID=your_github_client_id
GITHUB_CLIENT_SECRET=your_github_client_secret
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
```

## 📖 Documentation & Examples

For comprehensive documentation and examples, see:

- [Complete Usage Examples](https://github.com/QMM1222/better-auth-adapted/blob/main/EXAMPLES.md)
- [Better Auth Documentation](https://better-auth.com)
- [GitHub Repository](https://github.com/QMM1222/better-auth-adapted)

## 🤝 Contributing

Contributions are welcome! Please see our [contributing guidelines](https://github.com/QMM1222/better-auth-adapted/blob/main/CONTRIBUTING.md).

## 📄 License

MIT License - see [LICENSE](https://github.com/QMM1222/better-auth-adapted/blob/main/LICENSE) for details.

## 🆘 Support

- [GitHub Issues](https://github.com/QMM1222/better-auth-adapted/issues)
- [Better Auth Community](https://better-auth.com/docs)

---

Built with ❤️ on top of [Better Auth](https://better-auth.com)