Modern, TypeScript-first authentication library for Next.js (Beta) and React Router V7 (Upcoming).
β οΈ Warning This project is on its first release. I'm still trying out the idea. It has not been used in production.
- TypeScript First: Built from the ground up with TypeScript for excellent type safety
- Next.js 14/15 Support: Full App Router and Server Components support
- Multiple Providers: OAuth (Google, GitHub, etc.), Credentials, Email/Password
- JWT & Session Management: Secure token handling with refresh capabilities
- Database Adapters: Prisma, MongoDB, PostgreSQL, MySQL support
- Middleware Protection: Route protection with Next.js middleware
- React Router V7 Ready: Coming soon - full support for React Router
| Package | Version | Description |
|---|---|---|
| @airauth/core | 1.0.0-beta.0 | Core authentication library |
| @airauth/next | 1.0.0-beta.0 | Next.js integration |
| @airauth/react | 1.0.0-beta.0 | React hooks and components |
| @airauth/adapter-prisma | 1.0.0-beta.0 | Prisma database adapter |
| @airauth/react-router-v7 | Coming Soon | React Router V7 integration |
npm install @airauth/next @airauth/core
# or
yarn add @airauth/next @airauth/core
# or
pnpm add @airauth/next @airauth/core- Create your auth configuration (
app/api/auth/[...nextauth]/route.ts):
import { AirAuth } from '@airauth/next';
import GoogleProvider from '@airauth/next/providers/google';
const handler = AirAuth({
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID!,
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
}),
],
});
export { handler as GET, handler as POST };- Wrap your app with SessionProvider (
app/layout.tsx):
import { SessionProvider } from "@airauth/next/react"
export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<html lang="en">
<body>
<SessionProvider>{children}</SessionProvider>
</body>
</html>
)
}- Use authentication in your components:
"use client"
import { useSession, signIn, signOut } from "@airauth/next/react"
export default function Component() {
const { data: session, status } = useSession()
if (status === "authenticated") {
return (
<>
<p>Signed in as {session.user?.email}</p>
<button onClick={() => signOut()}>Sign out</button>
</>
)
}
return <button onClick={() => signIn()}>Sign in</button>
}Visit airauth.dev for full documentation, including:
We're working on comprehensive video tutorials and guides to help you get started:
- Step-by-step integration guide
- Building a complete auth system
- Advanced authentication patterns
- Best practices and security tips
Stay tuned for updates!
Check out our examples in the apps directory:
- Next.js Example - Complete Next.js App Router example
- React Router Example (Coming Soon)
This is a monorepo managed with Turbo and pnpm.
# Clone the repository
git clone https://github.com/n10l/airauth.git
cd airauth
# Install dependencies
pnpm install
# Build all packages
pnpm build
# Run tests
pnpm test
# Start development mode
pnpm devairauth/
βββ packages/
β βββ core/ # Core authentication library
β βββ next/ # Next.js integration
β βββ react/ # React hooks and components
β βββ adapter-*/ # Database adapters
βββ apps/
β βββ docs/ # Documentation site
β βββ example-nextjs/ # Example Next.js app
βββ turbo.json # Turbo configuration
Copy .env.example to .env and configure:
# Disable Next.js telemetry
NEXT_TELEMETRY_DISABLED=1
# Authentication
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=your-secret-key
# OAuth Providers
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
GITHUB_CLIENT_ID=your-github-client-id
GITHUB_CLIENT_SECRET=your-github-client-secretWe love contributions and encourage you to experiment with AirAuth! Whether you're fixing bugs, adding features, improving documentation, or sharing ideas - every contribution matters.
- π Report bugs and help us improve stability
- π‘ Suggest features that would make authentication better
- π Improve documentation to help others get started
- π§ͺ Experiment freely - try new approaches and share what you learn
- π Add translations to make AirAuth accessible globally
- β Star the repo to show your support
- Fork the repository and clone it locally
- Create your feature branch (
git checkout -b feature/amazing-idea) - Make your changes and test thoroughly
- Commit with clear messages (
git commit -m 'Add amazing feature') - Push to your branch (
git push origin feature/amazing-idea) - Open a Pull Request and tell us about your changes!
Don't hesitate to open an issue or discussion if you have questions. We're here to help and excited to see what you build!
See our Contributing Guide for detailed guidelines.
MIT Β© n10l
AirAuth is inspired by the excellent work of the NextAuth.js team and its contributors, particularly BalΓ‘zs OrbΓ‘n and the entire NextAuth.js community. Their pioneering work in creating a flexible authentication solution for Next.js has set the standard for developer-friendly auth libraries.
While AirAuth is built from the ground up with a focus on TypeScript-first design and modern Next.js features, we deeply appreciate the patterns and developer experience principles established by NextAuth.js. We aim to build upon these foundations while exploring new approaches to authentication in the evolving Javascript ecosystem.
AirAuth - Modern authentication for modern applications.
