Reference
API reference
Every export of the Mortar packages, generated from their TypeScript sources and comments.
@mortar-kit/core
ActionContextinterface- What the app passes to every action, besides the post: services that live on the server (a mailer, a database), so the brick's module (which the browser loads too) imports none of them.
ActionFormfunction- A form that posts to its brick's `action`.
ActionFormPropsinterface- Props of `ActionForm`.
ActionInputinterface- What a brick's `action` receives.
AnyBricktype- A brick of any schema, e.g. in a list of bricks.
AnyCollectiontype- A collection of any schema, e.g. in a list of collections.
AnyFieldtypeAssetinterface- An uploaded file, as `Assets.list` returns it.
AssetDetailsinterface- What editors set on an asset.
assetExtensionsfunction- The extensions of each kind, e.g. for an `<input type="file" accept>`.
AssetFolderinterface- A folder of assets (one level, no nesting).
assetInfofunction- The type, kind and display name of a valid key; undefined for anything else.
assetKeyForfunction- A fresh key for an uploaded file name: the name made URL-safe, six random letters and digits (so two uploads of `photo.jpg` never collide), and its extension.
AssetKindtype- What a file is, for choosing it: an image field accepts `image`, a file field the kinds it lists.
Assetsinterface- Uploaded files: what the admin's library and pickers need.
assetsInfunction- Every uploaded asset `data` uses (image and file fields with an `asset`), following objects and lists.
assetValuesInfunction- The image and file values in `data` (following objects and lists), each the object itself, with its path.
BlobInfointerface- A stored file, as `BlobStore.list` returns it.
BlobStoreinterface- Where uploaded files live: bytes by key.
Brickinterface- A registered brick.
BrickActionsinterface- How the app connects brick forms to the server.
BrickActionsContextvariable- Provides the app's `BrickActions` to every `PageView` below it.
BrickDefinitioninterface- What a developer passes to `defineBrick`.
BrickLoadertype- Loads one brick's module on demand and returns the brick (see `lazyBricks`).
brickMapfunction- Indexes bricks by name, rejecting duplicates.
BrickPropsinterface- Props every brick component receives.
ClientScriptsfunction- The hydration bootstrap and the client entry script, only on pages that hydrate.
Collectioninterface- A registered collection.
CollectionDefinitioninterface- What a developer passes to `defineCollection`.
collectionMapfunction- Indexes collections by name, rejecting duplicates.
CollectionWriteinterface- A write to one of a collection's documents, as the collection's `canWrite` sees it.
Contentinterface- Reading and writing documents: what the admin needs.
contentClientfunction- The app's content in the browser (and during SSR), over the functions of its "use server" module.
ContentClientinterface- What `contentClient` builds.
ContentClientOptionsinterface- Options for `contentClient`.
ContentContextvariable- Where bricks and layouts read content from.
ContentOptionsinterfacecontentReaderfunction- A typed reader over a source.
ContentReaderinterface- Typed reads: pass a collection, get its documents with typed fields.
ContentServerinterface- The content functions an app's "use server" module exports, by these names, for `contentClient`.
ContentSourceinterface- Reading documents by collection name: what bricks, layouts and routes need.
ContentStoreinterface- Where documents live: raw data by collection name and slug.
ContentWriteinterface- One write, as `canWrite` sees it.
ContentWriteActiontype- The writing functions of a `ContentServer`, by name.
createContentfunction- The rules around a store.
createMemoryBlobStorefunction- A blob store that keeps files in memory (tests, demos).
createMemoryStorefunction- A store that keeps documents in memory (tests, demos).
defaultOffunction- A fresh default value for one field.
defaultsOffunction- The default data for a record of fields (each field's own default).
defineBrickfunction- Registers a brick: a named component plus the schema of its data.
defineCollectionfunction- Registers a collection.
Docinterface- One document of a collection.
DocIssuetype- A problem found when validating a document.
DocOftype- The document type of a collection.
DocReftype- Which document: by id or by slug.
DocSummarytype- A document without its body, as lists return it.
EntryIssueinterface- A problem found when validating.
EntryRefinterface- Where an entry is stored: what a form post names, so the server can read the entry's data.
Fieldtype- A Mortar field: a Valibot schema whose output is `T`.
fieldInfofunction- Reads the UI description from a field, or `undefined` for a non-Mortar schema.
FieldInfointerface- UI description of a field, stored in its Valibot metadata under `mortar`.
FieldKindtype- The form widget a field is edited with.
fieldsvariable- Field helpers used to declare the schema of a brick or a collection.
Fieldstype- A record of named fields: the `schema` of a brick or an `object` field.
FileValueinterface- A file (video, audio, PDF…): an uploaded asset or a URL.
FolderResulttype- Result of `Assets.saveFolder`.
FoundAssetinterface- An uploaded asset used in some data: where, and its key.
FoundReferenceinterface- A reference found in some data: where it is, which collection, and the id it holds.
hasAssetFieldsfunction- Whether `schema` has an image or file field anywhere (following objects and lists).
hasIslandsfunction- True when the page (or `root`) has islands: the client entry's test for calling `hydrateIslands`.
hydrateIslandsfunction- Hydrates every island on the page: each interactive brick the server rendered on a page without JavaScript, on its own.
HydrateIslandsOptionsinterface- Options for `hydrateIslands`.
Imageinterface- An image: an uploaded asset (`asset` holds its key) or a URL, plus alt text and a title.
InferFieldstype- The data type described by a record of fields.
islandActionsfunction- `BrickActions` for islands (interactive bricks on pages without the router): a form post calls `run` in the background and only its brick updates, pending until the result (or error) is back.
IslandActionsOptionsinterface- What `islandActions` needs from the app.
IslandPayloadinterface- What an island's element carries to the browser (as JSON).
Issueinterface- A validation problem, located by its path inside the brick's data.
isValidAssetKeyfunction- Whether `key` is a valid asset key: `<name>-<6 letters or digits>.<known extension>`, at most 100 characters.
isValidDocIdfunction- Whether `id` is a valid document id: 1 to 64 letters, digits, `_` or `-` (a UUID fits).
isValidSlugfunction- Whether `slug` is a valid slug: up to 100 lowercase letters and digits, single dashes between (`home`, `about-us`).
lazyBricksfunction- Loaders by brick name, from your brick modules as `import.meta.glob` gives them (unloaded): each file is named after its brick (`bricks/contact-form.tsx` exports the brick named `contact-form`).
ListOptionsinterface- Options for listing documents.
MemoryBlobStoreOptionsinterface- Options for `createMemoryBlobStore`.
normalizeDocfunction- Coerces unknown data (a stored file, data from props) into a document that renders and edits safely.
normalizeEntriesfunction- Coerces unknown data into entries that render and edit safely: entries of known bricks get normalized data, entries of unknown bricks keep their data (as plain JSON), and malformed or duplicate entries are dropped.
PageEntryinterface- One brick instance in a body.
PageViewfunction- Renders every entry with its brick's component.
PageViewPropsinterfacereferencedCollectionsfunction- The collections that references in `schema` point to (following objects and lists).
referencesInfunction- Every non-empty reference in `data`, following `object` and `list` fields, so a list of references (`fields.list({ of: fields.reference(...) })`) is found item by item.
Referrerinterface- A document holding a reference, and where.
RemoveResulttype- Result of `Content.remove`.
RenderedPageinterface- What `createRender` tells the document about the page being rendered.
resolveUrlfunction- The document a path of the site shows, by the collections' `url` patterns: `/posts/hello` → `{ collection: 'posts', slug: 'hello' }`.
RunActionOptionsinterface- What the app passes to `Content.runAction` besides the post.
sameEntryfunction- True when `value` names the same entry as `ref`: for filtering submissions by entry.
SaveResulttype- Result of `Content.save`.
SchemaOpsinterface- What bricks and collections share: defaults, validation and normalization for a record of fields.
seedfunction- Saves starter documents into every collection of `docs` that has none yet, in the order given (so references can point at documents saved earlier).
SeedDocinterface- A starter document: like a `Doc`, but the id may be left out (a random one is made).
SeedResultinterface- What `seed` did.
serveBlobfunction- A response serving one stored file: for an app route or middleware such as `/uploads/*`.
sitemapfunction- A sitemap (sitemaps.org XML) of every document whose collection has a `url`, read through `content`.
SitemapOptionsinterface- Options for `sitemap`.
SortOrderinterface- A list order: by a field of the collection or by slug.
Submissioninterface- A form post to a brick's `action`, as its component sees it.
UpdateAssetResulttype- Result of `Assets.update`.
UploadResulttype- Result of `Assets.upload`.
useContentfunction- The content reader for the current component, from `ContentContext`.
useRenderedPagefunction- How the page being rendered is sent: whether it hydrates, and the CSP nonce for its scripts, so the app can put the nonce on its own scripts (analytics, an inline snippet) and leave out what only works with JavaScript.
validateDocfunction- Checks a document before it is saved: its id and slug (not one of the collection's reserved slugs), its fields against the collection's schema (issues at `['fields', ...]`), and with a body its entries.
ValidateDocResulttype- Result of `validateDoc`: the cleaned document, or every issue found.
validateEntriesfunction- Checks entries before they are saved: each entry's shape, unique ids, and its data against its brick's schema.
ValidateResulttype- Result of `brick.validate(data)`.
@mortar-kit/core/server
ContentServerOptionsinterface- Options for `createContentServer`.
createContentServerfunction- The server side of the app's content, for its "use server" module to export.
createFileBlobStorefunction- A blob store backed by a folder: one file per asset, named by its key (keys are checked, so none can escape `dir`).
createJsonFileStorefunction- A content store backed by JSON files.
FileBlobStoreOptionsinterfaceJsonFileStoreOptionsinterface
@mortar-kit/core/render
createRenderfunction- The server entry's `render`.
HydrateOptiontype- Which pages hydrate: all, none, these path prefixes, or a test of the path.
hydrateTestfunction- `hydrate` as a test of a path.
Rendertype- The server entry's `render`: a stream for pages that hydrate, the settled HTML for the rest.
RenderManifesttype- The asset manifest the server entry gets from `virtual:solid-manifest`.
RenderOptionsinterface- Options for `createRender`.
stylesOnlyfunction- A copy of `manifest` that resolves to CSS only.
@mortar-kit/admin
AdminfunctionAdminLocationinterface- Which collection the admin shows, and which document of it is open (by id); or, with `view: 'assets'`, the asset library (`collection` is then where the rail goes back to).
AdminPropsinterfaceAdminUserinterface- The signed-in user, as the admin shows them.
BrickFormfunction- The form for one entry, from its brick's schema.
BrickFormPropsinterfacecreateEditorStorefunction- Creates the editor store.
EditorfunctionEditorPropsinterfaceEditorStateinterfaceEditorStoreinterface- The editor's state and the only ways to change it.
FIELDSvariable- Selects (and addresses writes to) the document's fields instead of an entry.
Pathtype- A location inside an entry's data (or the document's fields).
PreviewFramefunctionPreviewFramePropsinterfaceSignInfunction- The sign-in page.
SignInMethodinterface- A sign-in method, as `auth.methods` (`@mortar-kit/auth`) lists it.
SignInParamsinterface- The sign-in page's search parameters, as the auth routes set them.
SignInPropsinterfaceTargettype- What a write is addressed to: an entry, by id, or the document's fields.
@mortar-kit/admin/preview
DocMessageinterface- Editor → preview: the full document to render, its collection's name and whether that collection has a body (sent on every change).
DocPreviewfunction- A readable preview of any document: its title, its first image large, then every other field under its label, then `children` (the body).
DocPreviewPropsinterfaceHelloMessageinterface- Editor → preview: the editor is listening now; answer with `mortar:ready`.
LinkMessageinterface- Preview → editor: a same-origin link was followed (⌘/Ctrl-click) in the preview.
PreviewLayouttype- Renders a document of one collection the way the site does, around its rendered body.
PreviewPagefunction- Renders the document the parent editor posts; empty until the first message.
PreviewPagePropsinterfaceReadyMessageinterface- Preview → editor: the preview has mounted and wants the current document.
RefreshMessageinterface- Editor → preview: saved content changed; data that bricks loaded should be fetched again.
SelectMessageinterface- Editor → preview: the selected entry, by id (null when the document's fields or nothing is selected), so the preview outlines it.
@mortar-kit/admin/router
AdminRoutefunction- `<Admin>` as a route of a @solidjs/router app: its location lives in the URL's search parameters, and leaving a document with unsaved changes (a link, back/forward, switching documents) asks first.
AdminRoutePropstype- `<Admin>`'s props, less what the route provides (the location and the leave guard).
@mortar-kit/admin/vite
mortarKitfunction- Mortar's Vite plugin.
MortarKitOptionsinterfaceMortarThemeinterface- A theme for the admin: what a theme package (e.g. `@mortar-kit/theme-midnight`) exports.
@mortar-kit/auth
allowEmailsfunction- An `authorize` that lets in these addresses, compared case-insensitively; `*@example.com` lets in a whole domain.
allowMembersfunction- An `authorize` that lets in anyone whose address is in a document of `collection` (compared case-insensitively).
AllowMembersOptionsinterface- Options for `allowMembers`.
Authinterface- Sign-in for the admin; see `createAuth`.
AuthErrortype- Why a sign-in failed: the `error` parameter of the sign-in page.
authFromEnvfunction- `createAuth` set up from the environment: the secret, who may sign in, Google when its client is configured, and email sign-in through Resend (or your `mailer`).
AuthFromEnvOptionsinterface- Options for `authFromEnv`.
AuthMethodinterface- A way to sign in.
AuthMethodContextinterface- What a sign-in method gets from `createAuth` for each request.
AuthMethodInfointerface- A sign-in method, as the sign-in page lists it.
AuthOptionsinterface- Options for `createAuth`.
AuthorizeInputinterface- What `authorize` receives.
AuthSuccessinterface- What a method's `callback` returns once it knows who someone is.
consoleMailerfunction- A mailer that prints each message (sign-in links and codes included) to the server's console instead of sending it.
createAuthfunction- Sign-in for the admin.
createLimiterfunction- A fixed-window counter per key: returns 0 while the key is under `max` hits in the current window, else the milliseconds until it resets.
createMiddlewarefunction- The site's middleware: put it in `start.middleware`.
createSealerfunction- A sealer over `secret`: one key, or several to rotate (the first signs, every one is accepted).
emailfunction- Sign in with a link or code sent by email.
EMAIL_TOKENS_COLLECTIONvariable- The reserved collection pending email sign-ins are stored in.
EmailOptionsinterface- Options for `email`.
EmailUserinterface- The user `allowEmails` signs in.
googlefunction- Sign in with a Google account.
GoogleOptionsinterface- Options for `google`.
Identityinterface- Who a sign-in method says someone is.
Mailerinterface- Sends email.
MailMessageinterface- One email to send.
MemberUsertype- The user `allowMembers` signs in: the address, a name, and the `fields` asked for.
Middlewaretype- A middleware for `start.middleware`.
MiddlewareEventinterface- What the middleware reads and writes on the request event (`StartRequestEvent` fits).
MiddlewareOptionsinterface- Options for `createMiddleware`.
resendMailerfunction- A mailer that sends through Resend.
ResendMailerOptionsinterface- Options for `resendMailer`.
Sealerinterface- Signs, checks and hashes values with the app's secret.