generateLuciaPasswordHash()#
Creates a new Lucia hash of a password. If you’re looking for a general hashing function, DO NOT use this API. The output hash is designed in a way to be compatible with older versions of Lucia. The sole purpose of this API is for interacting with Lucia keys stored in your database, and nothing else.
const generateLuciaPasswordHash: (password: string) => Promise<string>;
Parameters#
| name | type | description | 
|---|
password | number | Password to hash | 
 
Returns#
| type | description | 
|---|
string | Hash | 
 
generateRandomString()#
Generates a cryptographically random string. If argument for parameter alphabet is not provided, the result with consist of a-z0-9 (lowercase letters, numbers).
const generateRandomString: (length: number, alphabet?: string) => string;
Parameters#
| name | type | optional | description | 
|---|
length | number |  | Length string to generate | 
alphabet | string | ✓ | String of characters to generate the string from ` | 
 
Returns#
| type | description | 
|---|
string | Randomly generated string | 
 
isWithinExpiration()#
Checks with the current time is within the expiration time (in milliseconds UNIX time) provided.
const isWithinExpiration: (expiration: number) => boolean;
Parameters#
| name | type | description | 
|---|
expiration | number | Expiration time in milliseconds (UNIX time) | 
 
Returns#
| value | description | 
|---|
true | Is within expiration | 
false | Is expired | 
 
joinAdapters()#
This is an experimental API and can change or be removed.
Joins multiple adapters into a single adapter, allowing you to override specific methods.
import { __experimental_joinAdapters } from "lucia/utils";
const joinAdapters: (
	baseAdapter: InitializeAdapter<Adapter | SessionAdapter | UserAdapter>,
	...adapters: Array<
		Partial<Adapter> | InitializeAdapter<Adapter | SessionAdapter | UserAdapter>
	>
) => Adapter;
Parameters#
| name | type | 
|---|
baseAdapter | InitializeAdapter | 
adapters | array | 
 
Returns#
Usage#
import { lucia } from "lucia";
import { __experimental_joinAdapters as joinAdapters } from "lucia/utils";
import { betterSqlite3 } from "@lucia-auth/adapter-sqlite";
export const auth = lucia({
	adapter: joinAdapters(betterSqlite3(), {
		getUser: async (userId) => {
			// ...
		}
	})
});
parseCookie()#
ESM and TypeScript friendly cookie.parse() from cookie.
serializeCookie()#
ESM and TypeScript friendly cookie.serialize() from cookie.
validateLuciaPasswordHash()#
Validates a password hash generated by Lucia.
const validateLuciaPasswordHash: (
	password: string,
	passwordHash: string
) => Promise<boolean>;
Parameters#
| name | type | description | 
|---|
password | string | Password to compare against | 
passwordHash | string | Hashed password to validate | 
 
Returns#
| value | description | 
|---|
true | Is valid | 
false | Is invalid |