Translations of this page:

Zotero Plugin Development

This page is a work in progress.

Introduction to Zotero Plugins

Zotero plugins run within the Zotero desktop app and are built on the same technologies as legacy (pre-WebExtension) Firefox extensions and interact with Zotero's internal JavaScript API.

If you plan to write a plugin, you can start by taking a look at existing plugins such as ZotFile. (The official Hello World Zotero plugin is currently extremely dated.)

Alternatives to Zotero Plugins

Depending on your use case, it may be easier to create an external tool that uses the Web API to access Zotero libraries, read from (not write to!) the Zotero client's SQLite database, run ad hoc JavaScript within Zotero, or interact with one of the other APIs that the Zotero client exposes (e.g., for word processor integration).

The Zotero Plugins page (which takes an expansive view of the term “plugin”) can be very helpful in helping you develop your own Zotero-based tools.

Setting Up a Plugin Development Environment

When developing a Zotero client plugin, it's helpful to have Zotero run the plugin directly from source. After creating your plugin's source directory with sample code, you can tell Zotero to load the plugin by creating an extension proxy file. (This is a technique that used to be possible for Firefox extension development, though it's since been discontinued in Firefox.)

  1. Close Zotero.
  2. Create a text file in the 'extensions' directory of your Zotero profile directory named after the extension id (e.g., myplugin@mydomain.org). The file contents should be the absolute path to the root of your plugin source code directory, where your install.rdf file is located.
  3. Open prefs.js in the Zotero profile directory in a text editor and delete the lines containing extensions.lastAppBuildId and extensions.lastAppVersion. Save the file and restart Zotero. This will force Zotero to read the 'extensions' directory and install your plugin from source, after which you should see it listed in Tools → Add-ons. This is only necessary once.
  4. Whenever you start up Zotero after making a change to your extension code, start it from the command line and pass the -purgecaches flag to force Zotero to re-read any cached files. (You'll likely want to make an alias or shell script that also includes the -ZoteroDebugText and -jsconsole flags and perhaps -p <Profile>, where <Profile> is the name of a development profile.)
dev/client_coding/plugin_development.txt · Last modified: 2020/09/27 05:18 by dstillman