For years, I was tired of wrestling with overly complex authentication libraries.
Building my own authentication system needed much more care than I could ever imagine. Lucia comes with a simple, flexible, and type-safe authentication library designed for Astro, Express, Next.js, Nuxt, SolidStart, SvelteKit, and more! 🚀
Why Lucia?
Unlike other third-party authentication libraries like Clerk, NextAuth, or Supabase auth, Lucia takes a different approach. It's not a one-size-fits-all solution. Instead, Lucia empowers you to create authentication tailored precisely to your app's needs. No hidden configurations or callbacks that force you into a corner.
Key Features:
✅ Own your data with full control
✅ Secure with a focus on user privacy
✅ MIT license for open development
✅ Fully typed for TypeScript lovers
How Does Lucia Stand Out?
🔹 Flexibility: Customize your sign-in forms and APIs the way you want.
🔹 Integration: Direct support for Next.js, SvelteKit, and Astro SSR.
🔹 Database Support: Adapters for MySQL, Postgres, Sqlite, MongoDB, and Redis.
🔹 Custom User Attributes: Set any user attributes, similar to Firebase custom claims.
🔹 Low-Level Control: Manage user and session data easily.
Code Example:
import { Lucia } from "lucia";
const lucia = new Lucia(new Adapter(db));
const user = await lucia.createUser("email", userEmail, {
password: userPassword,
attributes: {
username: userUsername
}
});
const session = await lucia.createSession(user.userId);
const sessionCookies = lucia.createSessionCookies(session);
Comparison with Other Libraries:
🆚 Supabase auth, SuperTokens, NextAuth: These libraries have too much abstraction for users to have control over their authentication flow. Lucia gives you the tools to craft authentication that fits your app perfectly.
Demo Repo: Check out my example repo using Lucia with Next.js and Prisma ORM: Lucia Basic Starter
If you're tired of authentication libraries that dictate how you should build your app, give Lucia a try. Explore more about Lucia in the official documentation. Have questions? Feel free to reach out on GitHub or Discord. Let's empower our apps with flexible and secure authentication together! 🌟
Top comments (0)