Docs

Frontend-Basics

Frontend API ————

The frontend api supports two styles, regular scripts that are run with the current app and note context, and widgets that export an object to Trilium to be used in the UI. In both cases, the frontend api of Trilium is available to scripts running in the frontend context as global variable api. The members and methods of the api can be seen on the Script API page.

Scripts

Scripts don’t have any special requirements. They can be run at will using the execute button in the UI or they can be configured to run at certain times using Attributes on the note containing the script.

Global Events

This attribute is called #run and it can have any of the following values:

Entity Events

These events are triggered by certain relations to other notes. Meaning that the script is triggered only if the note has this script attached to it through relations (or it can inherit it).

Widgets

Conversely to scripts, widgets do have some specific requirements in order to work. A widget must:

parentWidget

Tutorial

For more information on building widgets, take a look at Widget Basics.