Skip to content

Config reference ​

Every option of easy-cms.config.ts, grouped by where it goes. For explanations and examples, follow the links to the guide. A test checks this page against the types in @easy-cms/core, so every option is listed here.

ts
import { defineConfig } from '@easy-cms/core'

export default defineConfig({ secret, db, collections, /* … */ })

Top level ​

OptionTypeDefault
secretstring—Required, 32+ characters. Signs sessions and preview tokens.
dbDatabaseAdapter—Required. sqlite() or postgres(). Databases
serverURLstring—Public origin (https://example.com); makes media URLs absolute.
corsstring[] | '*'[]Origins whose browser code may call the API. Security
cronSecretstringCRON_SECRETBearer secret for GET <api>/jobs/run. Scheduling
webhooksWebhookConfig[][]See webhooks.
localizationLocalizationConfig—See localization.
routesRoutesConfigSee routes.
adminAdminConfigSee admin.
uploadUploadConfigSee upload.
authAuthConfigSee auth.
collectionsCollectionConfig[][]See collections.
globalsGlobalConfig[][]See globals.
endpointsEndpoint[][]See endpoints.
commandsCliCommand[][]easy-cms <name> commands, e.g. from plugins: { name, description, help?, run({ cms, args, log }) }. CLI
apiKeysbooleanfalseAPI keys under Settings, for scripts and other apps. API keys
emailEmailAdapter—Sends email for plugins, e.g. smtp() or consoleEmail(). Email
pluginsPlugin[][](config) => config, run in order before validation. Plugins

routes ​

OptionTypeDefault
apistring/api/cmsWhere the REST API is served.

admin ​

OptionTypeDefault
pathstring/adminWhere the admin is served.
locale'en' | 'th'enDefault admin language before a user picks one.
brandAdminBrand{}See brand.
siteUrlstring/ (Nuxt, Next.js)The public site for "View site": a path or an http(s) URL.
menustring[]config orderCollection slugs in menu order; unlisted ones follow, media last.
modulesstring[][]Admin modules with Web Components: package exports or paths. Admin components

brand ​

OptionType
namestringShown in the menu, login page and browser tab. Default "Easy CMS".
logostringA path on your site or an https:// URL.
colorstringMain color as #rrggbb; shades are derived.

auth ​

OptionTypeDefault
rolesstring[]['admin', 'editor']Must include admin. Users & auth
tokenExpirationnumber604800 (7 days)Session lifetime in seconds.
maxLoginAttemptsnumber5Failed logins allowed per email (and IP) within lockWindow.
lockWindownumber900 (15 minutes)In seconds.
trustedOriginsstring[][]Other origins that may send cookie-authenticated requests.

upload ​

OptionTypeDefault
dirstringuploadsFolder for the default local storage, from the project root.
maxFileSizenumber10485760 (10 MB)In bytes.
mimeTypesstring[]['image/*', 'application/pdf']Allowed types, detected from file contents.
storageStorageAdapterlocal diskE.g. s3Storage() from @easy-cms/storage-s3. Uploads
imageSizesImageSize[][]Resized copies (needs sharp). See image sizes.

Image sizes ​

OptionTypeDefault
namestring—Key in media.sizes, e.g. thumbnail.
widthnumber—Width in pixels.
heightnumber—Optional height.
fit'cover' | 'contain' | 'inside'coverHow to fit when both width and height are set.

localization ​

OptionTypeDefault
localesstring[]—Content locales, e.g. ['th', 'en']. Localization
defaultLocalestringthe first localeUsed when no locale is given; its values fill empty ones.
fallbackbooleantrueReads return the default locale's value when a value is empty.

webhooks ​

OptionTypeDefault
urlstring—Where to POST events. Webhooks
eventsstring[]allcreate, update, delete, publish, unpublish, draft.
collectionsstring[]allCollections to send events for; [] for none.
globalsstring[]allGlobals to send events for; [] for none.
secretstring—Signs bodies: x-easy-cms-signature: sha256=<hex>.
headersRecord<string, string>—Extra request headers.

collections ​

OptionTypeDefault
slugstring—Required. URL and table name: lowercase letters, digits, -, _.
fieldsField[]—Required. See the field reference.
labels{ singular?, plural? }from the slugEach a string or { en, th }.
iconAdminIconfile-textMenu icon. Branding
useAsTitlestring—Top-level field shown as the document title.
editIn'page' | 'drawer'pagedrawer edits in a panel over the list (without drafts, versions or preview).
draftsbooleanfalseAdds status (draft | published). Drafts
versionsboolean | VersionsConfigfalseKeep a version of every save. See versions.
schedulebooleanfalsePublish and unpublish at a set time (needs drafts).
preview({ doc, locale }) => string | null—The page showing a document, for live preview.
access{ read?, create?, update?, delete? }logged inAccess control
hooksCollectionHooks—See hooks.
adminCollectionAdmin—See admin components.

versions ​

OptionTypeDefault
maxnumber50Versions kept per document; older ones are deleted.

hooks ​

Each is a list of functions. Hooks

HookArgumentsReturn
beforeValidatedata, operation, originalDoc?new data, or nothing
beforeChangedata, operation, originalDoc?new data, or nothing
afterChangedoc, operation, previousDoc?—
beforeDeleteid—
afterDeleteid, doc—
afterReaddocnew doc, or nothing

Every hook also gets user, cms and slug.

Admin components ​

OptionType
sidebarAdminComponent[]Panels in the edit page's side column. Admin components
group'settings'List the collection under Settings in the menu, with Users and API keys.
list{ tree?, sort? }The list page: tree names a relationship to the same collection to show a tree (top-level documents first, children open below); sort is the default order, e.g. 'title'.

globals ​

OptionTypeDefault
slugstring—Required.
fieldsField[]—Required.
labelstring | { en, th }from the slug
iconAdminIconsettingsMenu icon.
draftsbooleanfalse
versionsboolean | VersionsConfigfalse
schedulebooleanfalseNeeds drafts.
preview({ doc, locale }) => string | null—
access{ read?, update? }logged in
hooksGlobalHooks—See below.
adminContainerAdmin—{ sidebar }, as for collections.

Global hooks ​

HookArgumentsReturn
beforeChangedata, operation, originalDoc?new data, or nothing
afterChangedoc, operation, previousDoc?—
afterReaddocnew doc, or nothing

endpoints ​

OptionType
pathstringUnder routes.api, e.g. /seo/generate or /stats/:collection.
method'get' | 'post' | 'put' | 'patch' | 'delete'
handler(request: EndpointRequest) => unknownReturns a Response, or a value sent as JSON. Endpoints
rootbooleanServe the path from the site's root (standalone server only), e.g. /robots.txt. Default false.

EndpointRequest ​

PropertyType
requestRequestThe Web request.
urlURLIts URL.
paramsRecord<string, string>Values of :name segments.
userAuthUser | nullThe logged-in user.
ipstring | undefinedThe client's IP address, when the adapter knows it.
cmsEasyCMSThe Local API.
json() => Promise<object>The JSON body (an object, at most 1 MB).

Released under the MIT License.