Flipper Desktop plugins have a rigid structure. We recommend to scaffold any new plugin using our scaffolding tooling.
Scaffolding a new plugin
The CLI tool
flipper-pkg helps to initialize, validate, and package Flipper desktop plugins.
To scaffold a new plugin run
npx flipper-pkg init in the directory where you want to store the plugin sources.
Note that this should typically not be inside a Flipper checkout, but rather a fresh directory which you can put under your own source control.
Desktop Plugin structure
All Flipper Desktop plugins must be self-contained in a directory. This directory must contain at a minimum package.json and entry source file, e.g.:
After scaffolding a new plugin has finished, you should have files
src/index.tsx files in the directory. The first file is the plugin package manifest and the second is the entry point to your plugin. An example
package.json file could look like this:
Important attributes of
$schemamust contain URI identifying scheme according to which the plugin is defined. Currently, Flipper supports plugins defined by the specification version 2 (https://fbflipper.com/schemas/plugin-package/v2.json), while version 1 is being deprecated.
nameNpm package name. Should start with
flipper-plugin-by convention, so Flipper plugins can be easily found on npm.
idUsed as the plugin native identifier and must match the mobile plugin identifier, e.g. returned by
getIdmethod of your Java plugin.
mainPoints to the plugin bundle which will be loaded by Flipper. The "flipper-pkg" utility uses this field to determine output location during plugin bundling.
flipperBundlerEntryPoints to the source entry point which will be used for plugin code bundling. "flipper-pkg" takes the path specified in
flipperBundlerEntryas source, transpiles and bundles it, and saves the output to the path specified in
keywordsThe field must contain the
flipper-pluginkeyword, otherwise Flipper won't discover the plugin. Additionally, the field can also contain any other keywords for better plugin discoverability.
titleShown in the main sidebar as the human-readable name of the plugin.
iconDetermines the plugin icon which is displayed in the main sidebar. The list of available icons is static for now: https://github.com/facebook/flipper/blob/master/desktop/static/icons.json.
bugsSpecify an email and/or url, where plugin bugs should be reported.
Some public plugins will use a
FlipperPlugin base class. This format is deprecated but the documentation can still be found here.
Anatomy of a Desktop plugin
Flipper Desktop plugins come in three possible flavors:
- Client plugins: A plugin that connects to a specific client plugin running in an app (recommended)
- Device plugins: A plugin that doesn't connect to a specific client and doesn't have a native counter part, but rather shows data about the device obtained through some other means, like device logs, device temperatures, etc.
- Table plugin: A simplified version of a client plugin, that merely displays incoming data from a client plugin in a table.
Creating a Client Plugin
A plugin always exposes two elements from its entry module (typically
A further guide on how to write custom Flipper plugins can be found here: tutorial.
Creating a Device Plugin
Flipper also supports so-called device plugins - plugins that are available for an entire device - but don't receive a connection to a running app, so are a bit more limited in general. Their entry module anatomy is:
Device plugins work in general similar to normal client plugins, so aren't worked out in detail in this document. The available APIs for device plugins are listed here.
Creating a simple table plugin
Flipper provides a standard abstraction to render data received from a Client plugin in a table, see creating a table plugin.
Plugin definition can be validated using command
flipper-pkg lint. The command shows all the mismatches which should be fixed to make plugin definition valid.
Transpilation and bundling
We recommend you use TypeScript for the best development experience. We also recommend you use the file extension
.tsx when using TypeScript which adds support for inline React expressions.
As we already mentioned, the Flipper development build automatically transpiles and bundles plugins on loading. It is capable of all the ES6 goodness, Flow annotations, TypeScript, as well as JSX and applies the required babel-transforms.
The Flipper release build, in contrast, does not transpile or bundle plugins on loading. For production usage, plugins should be bundled before publishing using flipper-pkg. This utility applies the same modifications as the plugin loader of the development build.
flipper-pkg tool is published to npm and should be installed as a
devDependency for the plugin package.
Then, to bundle the plugin, execute the following command in its folder:
This command reads the
package.json, takes the path specified in the
flipperBundleEntry field as entry point, transpiles and bundles all the required code, and outputs the produced bundle to the path specified in field
You can get the list of other available commands by invoking
flipper-pkg help, and get detailed description for any command by invoking
flipper-pkg help [COMMAND]. You can also check README on npmjs.com for usage details: https://www.npmjs.com/package/flipper-pkg.
If you need any dependencies in your plugin, you can install them using
Migration to new Plugin Specification
Flipper plugins are defined according to the specification. As with any specification, it is evolving, so new versions of it can be released. Currently Flipper supports plugins defined using version 2 of specification which is described in this page. Previous version of specification is being deprecated, and we encourage all the plugins still using it to migrate.
The main difference of version 2 is that plugins are transpiled and bundled before packaging, while in version 1 this was done in run-time on plugin installation. There are no plugin API changes, so only the
package.json changes are required to migrate.
The easiest way for migration is using of command
flipper-pkg migrate. It will automatically migrate your plugin definition to the latest version.