SuperImpress

Better Auth

Decision to use better-auth for authentication

SuperImpress uses better-auth for authentication.

Why better-auth

  • Zero Boilerplate: Minimal configuration to get started
  • OAuth Providers: Built-in support for Google, GitHub, and more
  • Database Adapters: First-class Drizzle ORM integration
  • Framework Support: Official Elysia plugin

Integration

better-auth integrates with Elysia via the official plugin:

import { Elysia } from 'elysia';
import { auth } from './auth';

const app = new Elysia()
  .use(auth.plugin)
  .get('/protected', ({ user }) => {
    return { message: `Hello, ${user.name}` };
  }, { auth: true });

The { auth: true } route option automatically:

  • Validates the session
  • Rejects unauthenticated requests with 401
  • Provides typed user object in the handler

References

On this page