55555-Jyeon / Clerk_Lucia

Modern Authentication with NextJS (Clerk and Lucia)
0 stars 0 forks source link

Lucia #1

Open 55555-Jyeon opened 1 month ago

55555-Jyeon commented 1 month ago
🔗 documentation → https://lucia-auth.com/




1️⃣ installation

npm install lucia


2️⃣ initialize Lucia

import { Lucia } from "lucia";

const adapter = new BetterSQLite3Adapter(db); // your adapter

export const lucia = new Lucia(adapter, {
    sessionCookie: {
        attributes: {
            // set to `true` when using HTTPS
            secure: process.env.NODE_ENV === "production"
        }
    }
});

// IMPORTANT!
declare module "lucia" {
    interface Register {
        Lucia: typeof lucia;
    }
}


55555-Jyeon commented 1 month ago
import { Lucia } from "lucia";

const lucia = new Lucia(new Adapter(db));

const session = await lucia.createSession(userId, {});
await lucia.validateSession(session.id);