elysia-auth
elysia-auth is a powerful authentication middleware for Elysia.js applications, built on top of @auth/core
. It provides seamless integration with various authentication providers and robust middleware solutions for protecting your routes.
Features
-
🔒 Multiple Auth Providers - Support for 50+ authentication providers including:
- OAuth providers (Google, GitHub, Discord, etc.)
- Email/Password authentication
- JWT-based authentication
- And many more!
-
🛡️ Flexible Protection - Two middleware approaches:
authGuard
for route-specific protectionprotectPaths
for global path-based protection
-
🎯 Easy Integration - Simple setup with Elysia.js applications
-
🔑 Session Management - Built-in JWT session handling
-
⚡ Performance - Optimized for Bun’s runtime
Quick Start
bun add elysia-auth
Basic usage:
import { Elysia } from 'elysia'
import { ElysiaAuth, authGuard } from 'elysia-auth'
const app = new Elysia()
.use(ElysiaAuth({
secret: process.env.AUTH_SECRET,
providers: [
// Your auth providers
]
}))
.group('/admin', app => app
.use(authGuard())
.get('/dashboard', () => 'Protected Dashboard')
)
.listen(3000)
Why elysia-auth?
- Built for Elysia - Designed specifically for Elysia.js applications
- Type-Safe - Full TypeScript support
- Flexible - Multiple authentication strategies
- Production-Ready - Battle-tested auth patterns
Next Steps
- Check the Getting Started guide
- Learn about Authentication Providers
- Explore Advanced Usage