Building authentication is hard. Building it securely is even harder. We've all been there:
- 😩 Spending days setting up auth instead of building features
- 🔧 Wrestling with OAuth provider documentation
- 🎨 Building the same login forms over and over
- 🔒 Worrying about security vulnerabilities
- 📚 Dealing with incomplete or confusing documentation
Easy Auth SDK solves all of this. One package, five minutes, and you're done.
// This is all you need. Seriously.
import { createAuthHandlers } from 'easy-auth-sdk/next'
export const { GET, POST } = createAuthHandlers({
database: { url: process.env.DATABASE_URL },
providers: { google: { enabled: true } }
})
npm install easy-auth-sdk That's it. No complex configuration. Sensible defaults. It just works. |
Pre-built components with Shadcn UI + Tailwind. Fully customizable or bring your own. |
Rate limiting, CSRF protection, secure sessions, and password policies built-in. Sleep easy. |
First-class Next.js support. Express coming soon. Works with any Node.js app. |
Email/password, OAuth (Google, GitHub, etc.), password reset, and more out of the box. |
Full type safety. Autocomplete everything. Catch errors before runtime. |
npm install easy-auth-sdk
# Required peer dependencies (if not already installed)
npm install react react-dom next
# .env.local
DATABASE_URL="postgresql://user:pass@localhost:5432/myapp"
AUTH_SECRET="your-secret-key-min-32-chars" # Generate with: openssl rand -base64 32
// app/api/auth/[...auth]/route.ts
import { createAuthHandlers } from 'easy-auth-sdk/next'
export const { GET, POST } = createAuthHandlers({
database: {
type: 'postgres',
url: process.env.DATABASE_URL!
},
session: {
secret: process.env.AUTH_SECRET!
},
providers: {
emailPassword: { enabled: true },
google: {
clientId: process.env.GOOGLE_CLIENT_ID!,
clientSecret: process.env.GOOGLE_CLIENT_SECRET!
}
}
})
// app/layout.tsx
import { NextAuthProvider } from 'easy-auth-sdk/next/client'
export default function RootLayout({ children }) {
return (
<html>
<body>
<NextAuthProvider>
{children}
</NextAuthProvider>
</body>
</html>
)
}
// app/login/page.tsx
'use client'
import { AuthComponent } from 'easy-auth-sdk/react'
import { useNextAuth } from 'easy-auth-sdk/next/client'
export default function LoginPage() {
const { signIn, signUp, oauthSignIn, loading, error } = useNextAuth()
return (
<AuthComponent
onSignIn={signIn}
onSignUp={signUp}
onOAuthSignIn={oauthSignIn}
providers={[
{ id: 'google', name: 'Google' },
{ id: 'github', name: 'GitHub' }
]}
loading={loading}
error={error}
/>
)
}
That's it! You now have a fully functional auth system with:
- ✅ Beautiful login/signup UI
- ✅ Email/password authentication
- ✅ Social logins
- ✅ Secure sessions
- ✅ Password reset flow
- ✅ TypeScript support
All components are:
- 🎨 Beautifully designed with Shadcn UI
- 📱 Fully responsive out of the box
- ♿ Accessible (WCAG 2.1 compliant)
- 🎯 Customizable with Tailwind classes
- 🌙 Dark mode ready
import { getServerSession } from 'easy-auth-sdk/next/server'
import { redirect } from 'next/navigation'
export default async function DashboardPage() {
const session = await getServerSession()
if (!session) {
redirect('/login')
}
return <h1>Welcome, {session.user.name}!</h1>
}
'use client'
import { withNextAuth } from 'easy-auth-sdk/next/client'
function ProtectedComponent() {
return <div>Secret content 🤫</div>
}
export default withNextAuth(ProtectedComponent)
Setting up OAuth is as simple as adding credentials:
providers: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID!,
clientSecret: process.env.GOOGLE_CLIENT_SECRET!
},
github: {
clientId: process.env.GITHUB_CLIENT_ID!,
clientSecret: process.env.GITHUB_CLIENT_SECRET!
},
// Add more providers...
}
📋 Supported Providers
- ✅ GitHub
- ✅ Twitter/X
- ✅ Microsoft (coming soon)
- ✅ Apple (coming soon)
- ✅ Discord (coming soon)
- ✅ Custom OAuth
:root {
--primary: 220 90% 56%; /* Your brand color */
--primary-foreground: 0 0% 100%; /* Text on primary */
/* ... more variables */
}
<AuthComponent
className="custom-auth-wrapper"
texts={{
signIn: {
title: "Welcome Back! 👋",
description: "Sign in to continue your journey"
}
}}
/>
import { useNextAuth } from 'easy-auth-sdk/next/client'
function CustomLoginForm() {
const { signIn, loading, error } = useNextAuth()
// Build your own UI
return (
<form onSubmit={(e) => {
e.preventDefault()
signIn(email, password)
}}>
{/* Your custom form */}
</form>
)
}
const config = {
security: {
rateLimit: {
maxAttempts: 5,
windowMs: 15 * 60 * 1000 // 15 minutes
},
passwordPolicy: {
minLength: 8,
requireUppercase: true,
requireNumbers: true,
requireSpecialChars: true
},
csrf: {
enabled: true
}
}
}
const config = {
callbacks: {
onSignUp: async ({ user }) => {
// Send welcome email
await sendWelcomeEmail(user.email)
// Track analytics
analytics.track('user_signup', { userId: user.id })
},
onSignIn: async ({ user, account }) => {
// Update last login
await updateLastLogin(user.id)
},
onSignOut: async ({ user }) => {
// Cleanup tasks
await clearUserCache(user.id)
}
}
}
Easy Auth automatically creates and manages these tables:
┌─────────────┐ ┌──────────────┐ ┌──────────────┐
│ users │ │ accounts │ │ sessions │
├─────────────┤ ├──────────────┤ ├──────────────┤
│ id │◄────┤ userId │◄────┤ userId │
│ email │ │ provider │ │ sessionToken │
│ name │ │ providerId │ │ expiresAt │
│ password │ │ accessToken │ │ createdAt │
│ verified │ │ refreshToken │ │ updatedAt │
│ createdAt │ │ createdAt │ └──────────────┘
│ updatedAt │ │ updatedAt │
└─────────────┘ └──────────────┘
# Generate migration files
npx drizzle-kit generate:pg
# Apply migrations
npx drizzle-kit push:pg
# View database studio
npx drizzle-kit studio
Moving from NextAuth? It's seamless:
- import NextAuth from 'next-auth'
- import GoogleProvider from 'next-auth/providers/google'
+ import { createAuthHandlers } from 'easy-auth-sdk/next'
- export default NextAuth({
- providers: [
- GoogleProvider({
- clientId: process.env.GOOGLE_CLIENT_ID,
- clientSecret: process.env.GOOGLE_CLIENT_SECRET,
- })
- ]
- })
+ export const { GET, POST } = createAuthHandlers({
+ providers: {
+ google: {
+ clientId: process.env.GOOGLE_CLIENT_ID!,
+ clientSecret: process.env.GOOGLE_CLIENT_SECRET!
+ }
+ }
+ })
Full Migration Guide →
- Database Compatible: Our schema is NextAuth-compatible
- Similar API: Most functions have direct equivalents
- Better DX: Less configuration, more features
- Migration Script: Coming soon!
cd examples/next-app
npm install
npm run dev
cd examples/express-app
npm install
npm run dev
- [x] Email/Password authentication
- [x] OAuth providers (Google, GitHub, etc.)
- [x] Next.js integration
- [x] Beautiful UI components
- [x] TypeScript support
- [x] Rate limiting & security
- [ ] Two-factor authentication (2FA)
- [ ] Magic link authentication
- [ ] Express.js adapter
- [ ] Remix adapter
- [ ] Email service integrations
- [ ] Admin dashboard
- [ ] Multi-tenant support
We love contributions! Please see our Contributing Guide for details.
# Clone the repo
git clone https://github.com/your-org/easy-auth-sdk
# Install dependencies
npm install
# Run tests
npm test
# Build
npm run build
MIT © Your Company
If Easy Auth helped you ship faster, consider sponsoring the project!