Logo Trilium Rocks!

Scripting Guide

This guide is for developers looking to create their own scripts and addons for Trilium. It's not an exhaustive tutorial on everything possible within Trilium but it should give you a good idea of what Trilium is capable of and even put you on track for creating your own scripts.

About Scripting#

If you weren't already aware, Trilium currently supports two different types of scripts namely frontend and backend. Both script types are written in JavaScript since Trilium itself is a web-based app. Scripts themselves are stored, bundled, and run all within Trilium itself. Each script type has a corresponding note type in Trilium. There is even a specific UI for running these scripts on demand.

Article Image

There are also ways to trigger scripts to run at other times or on specific events, but that will be covered later in the guide.

Frontend Scripts#

There are actually two types of frontend scripts, 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 FrontendScriptApi page.

Backend Scripts#

Unlike the frontend scripts, there is only a single type of backend script available in Trilium. However much like the frontend, the backend api of Trilium is available to scripts running in the backend context as global variable api. The members and methods of the api can be seen on the BackendScriptApi page.

Guide Structure#

This guide is broken up into a few different sections. First there is the Getting Started section which is common to both types of scripts and it goes more in depth about how to create scripts and how they work. Then we have the Frontend and Backend sections which contain information specific to each type of script. Then we have the Releasing section which is once again common to both kinds of scripts.