Using Node.js APIs
Flipper plugins should be designed to work inside browsers as Flipper isn't guaranteed to always run on top of Electron.
For that reason, you should avoid using Node.js APIs directly (with, for example, modules like fs
, child_process
, path
), or packages that depend on the plugins.
The most important Node APIs can be found by using getFlipperLib()
(exposed by the flipper-plugin
package). Please note that these APIs are all promisified:
fs
- usegetFlipperLib().remoteServerContext.fs
instead.child_process
- usegetFlipperLib().remoteServerContext.childProcess.exec
. Note that this API is intended for short lived processes only.path
- useimport {path} from 'flipper-plugin'
instead.os
- usegetFlipperLib().environmentInfo.os
instead.- For system-specific directories such as 'home' and 'desktop', use
getFlipperLib().paths.homePath
and similar.
- For system-specific directories such as 'home' and 'desktop', use
In the future, these APIs may be subject to further security / permission restrictions to better sandbox plugins.