Interfaces

These types can be imported from lucia.

import type { Adapter } from "lucia";

Adapter#

See Database adapter API.

Auth#

See Auth.

AuthRequest#

See AuthRequest.

Configuration#

See configuration.

type Cookie = {
	name: string;
	value: string;
	attributes: CookieAttributes;
	serialize: () => string;
};
Properties#
propertytypedescription
namestringCookie name
valuestringCookie value
attributesCookieAttributesCookie attributes
type CookieAttributes = Partial<{
	domain: string;
	encode: (value: string) => string;
	expires: Date;
	httpOnly: boolean;
	maxAge: number;
	path: string;
	priority: "low" | "medium" | "high";
	sameSite: true | false | "lax" | "strict" | "none";
	secure: boolean;
}>;

serialize()#

Serializes the cookie into a Set-Cookie HTTP response header value.

const serialize: () => string;

Env#

type Env = "DEV" | "PROD";

InitializeAdapter#

type InitializeAdapter<_Adapter> => (LuciaError: LuciaErrorConstructor) => _Adapter

Key#

type Key = {
	userId: string;
	providerId: string;
	providerUserId: string;
	passwordDefined: boolean;
};
Properties#
nametypedescription
providerIdstringProvider id
providerUserIdstringProvider user id
userIdstringUser id of linked user
passwordDefinedbooleantrue if holds a password

KeySchema#

type KeySchema = {
	id: string;
	hashed_password: string | null;
	user_id: string;
};

LuciaErrorConstructor#

Constructor for LuciaError.

const LuciaErrorConstructor: (message: string) => LuciaError;

LuciaRequest#

type LuciaRequest = {
	method: string;
	url: string;
	headers: {
		origin: string | null;
		cookie: string | null;
		authorization: string | null;
	};
	storedSessionCookie?: string | null;
};
Properties#

Optional property storedSessionCookie is for frameworks with APIs to directly read and set cookies.

propertytypeoptionaldescription
methodstringRequest url (case insensitive)
urlstringFull request url (e.g. http://localhost:3000/pathname)
headers.originstring | nullOrigin header value
headers.cookiestring | nullCookie header value
headers.authorizationstring | nullAuthorization header value
storedSessionCookiestring | nullSession cookie value

Middleware#

See Middleware API.

RequestContext#

See Middleware API.

Session#

type Session = {
	user: User;
	sessionId: string;
	activePeriodExpiresAt: Date;
	idlePeriodExpiresAt: Date;
	state: "idle" | "active";
	fresh: boolean;
} & ReturnType<_Configuration["getSessionAttributes"]>;
Properties#

ReturnType<_Configuration["getSessionAttributes"]> represents the return type of getSessionAttributes() configuration.

nametypedescription
activePeriodExpiresAtDateTime of the active period expiration
idlePeriodExpiresAtDateTime of the idle period expiration
freshbooleantrue if the session was newly created or reset
sessionIdstringSession id
state"active" | "idle"Session state
userUserUser of the session

SessionAdapter#

See Database adapter API.

SessionSchema#

type SessionSchema = {
	id: string;
	active_expires: number;
	idle_expires: number;
	user_id: string;
} & Lucia.DatabaseSessionAttributes;

User#

type User = {
	userId: string;
} & ReturnType<_Configuration["getUserAttributes"]>;
Properties#

ReturnType<_Configuration["getUserAttributes"]> represents the return type of getUserAttributes() configuration.

nametypedescription
userIdstringUser id

UserAdapter#

See Database adapter API.

UserSchema#

type UserSchema = {
	id: string;
} & Lucia.DatabaseUserAttributes;