All pages
Powered by GitBook
1 of 1

Loading...

Context API

context.environment

Includes the following properties:

  • appPath: Path to running Local by Flywheel.app

  • userHome: Path to current user home directory

  • phpVersion: Available PHP versions in Local

  • version: Local version

  • dockerPath: Path to Docker binary in Local by Flywheel.app

  • userDataPath: Path to Local's user data folder. On macOS this defaults to ~/Library/Application Support/Local by Flywheel

context.hooks

Use context.hooks to run actions at certain times. Hooks are especially useful when adding in element with context.React.

context.electron

Exposes . The available methods and classes will differ based on whether or not this is ran from the main process or renderer process.

With the Electron API you can create dialogs, open new windows, and more.

context.fileSystem

​ npm package, which extends the native in Node.js.

context.fileSystemJetpack

​ npm package. Some may prefer it over the native in Node.js.

context.notifier

​ npm package. The main method in this class is notify.

Example

context.process

Node.js object.

context.React

Renderer Only

context.React required to use JSX in your renderer entry point. You can also use context.React to access React's .

context.ReactRouter

  • Link -

  • NavLink -

  • Route -

Deprecated

The following contexts have been deprecated in the most recent versions of Local.

context.request

​ npm package, which makes it very easy to send HTTP/HTTPS requests.

The request package was deprecated on Feb 11th 2020, and removed from Local in the [v8.0.0]() release.

context.docker

Use context.docker to run Docker commands.

Example

Router - https://reactrouter.com/web/api/Router

Electron API
fs-extra
fs API
fs-jetpack
fs API
node-notifier
process
Top-Level API
https://reactrouter.com/web/api/Link
https://reactrouter.com/web/api/NavLink
https://reactrouter.com/web/api/Route
request
https://community.localwp.com/t/local-beta-8-0-0/39385
context.notifier.notify({  
    title: 'Notification Title',  
    message: 'This is an example notification message.',
});
context.docker(`start ${container}`).then(stdout => {    
    //Success
}).catch(({stdout, stderr}) => {    
    //Something bad happened
});