Skip to content

n10l/airauth

Repository files navigation

AirAuth πŸ”

Modern, TypeScript-first authentication library for Next.js (Beta) and React Router V7 (Upcoming).

npm version npm downloads Bundle Size License: MIT TypeScript Next.js PRs Welcome GitHub Stars Twitter Follow

⚠️ Warning This project is on its first release. I'm still trying out the idea. It has not been used in production.

AirAuth Landing Page

πŸš€ Features

  • 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

πŸ“¦ Packages

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

πŸƒβ€β™‚οΈ Quick Start

Installation

npm install @airauth/next @airauth/core
# or
yarn add @airauth/next @airauth/core
# or
pnpm add @airauth/next @airauth/core

Basic Setup

  1. 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 };
  1. 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>
  )
}
  1. 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>
}

πŸ“– Documentation

Visit airauth.dev for full documentation, including:

πŸ“Ί Tutorials (Coming Soon!)

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!

🎯 Examples

Check out our examples in the apps directory:

  • Next.js Example - Complete Next.js App Router example
  • React Router Example (Coming Soon)

πŸ› οΈ Development

Build Status Test Coverage Code Quality

This is a monorepo managed with Turbo and pnpm.

Setup

# 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 dev

Project Structure

airauth/
β”œβ”€β”€ 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

Environment Variables

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-secret

🀝 Contributing

We love contributions and encourage you to experiment with AirAuth! Whether you're fixing bugs, adding features, improving documentation, or sharing ideas - every contribution matters.

How You Can Help

  • πŸ› 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

Getting Started

  1. Fork the repository and clone it locally
  2. Create your feature branch (git checkout -b feature/amazing-idea)
  3. Make your changes and test thoroughly
  4. Commit with clear messages (git commit -m 'Add amazing feature')
  5. Push to your branch (git push origin feature/amazing-idea)
  6. 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.

πŸ“ License

MIT Β© n10l

πŸ™ Acknowledgments

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.

πŸ”— Links


AirAuth - Modern authentication for modern applications.

About

πŸ‘‹ Authentication for NextJS ⏰ Stay tuned

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages