Skip to content

Configuring Lucid

At the core of any Lucid project is the Lucid configuration file, located at the root of your project. This file is where you define collections, plugins, hooks, media, email strategies, and more. Lucid dynamically imports this file at runtime, and it is used throughout the core library.

Example

lucid.config.ts
import lucid from "@lucidcms/core";
import { LibSQLAdapter } from "@lucidcms/core/adapters";
// Plugins
import LucidNodemailer from "@lucidcms/plugin-nodemailer";
import LucidS3 from "@lucidcms/plugin-s3";
import LucidLocalStorage from "@lucidcms/plugin-local-storage";
// Collections
import { PageCollection, SettingsCollection } from "./collections.js";
export default lucid.config({
host: "http://localhost:8080",
db: new LibSQLAdapter({
url: "libsql://localhost:8080?tls=0",
}),
keys: {
encryptionKey: process.env.LUCID_ENCRYPTION_KEY as string,
cookieSecret: process.env.LUCID_COOKIE_SECRET as string,
refreshTokenSecret: process.env.LUCID_REFRESH_TOKEN_SECRET as string,
accessTokenSecret: process.env.LUCID_ACCESS_TOKEN_SECRET as string,
},
localisation: {
locales: [
{
label: "English",
code: "en",
},
{
label: "French",
code: "fr",
},
],
defaultLocale: "en",
},
hooks: [
{
service: "collection-documents",
event: "beforeUpsert",
handler: async (props) => {},
},
],
collections: [PageCollection, SettingsCollection],
plugins: [
LucidNodemailer({
from: {
name: "Lucid",
},
transporter: transporter,
}),
LucidLocalStorage({
uploadDir: "uploads",
}),
],
});

Config Interface

export interface LucidConfig {
db: DatabaseAdapter;
host: string;
keys: {
encryptionKey: string;
cookieSecret: string;
accessTokenSecret: string;
refreshTokenSecret: string;
};
disableSwagger?: boolean;
localisation?: {
locales: {
label: string;
code: string;
}[];
defaultLocale: string;
};
paths?: {
emailTemplates?: string;
};
email?: {
from: {
email: string;
name: string;
};
strategy: EmailStrategy;
};
media?: {
storage?: number;
maxSize?: number;
processed?: {
limit?: number;
store?: boolean;
};
fallbackImage?: string | boolean | undefined;
strategy?: MediaStrategy;
};
hooks?: Array<AllHooks>;
collections?: CollectionBuilder[];
plugins?: LucidPlugin[];
}