# 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` <a href="#context-hooks" id="context-hooks"></a>

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

## `context.electron` <a href="#context-electron" id="context-electron"></a>

Exposes [Electron API](http://electron.atom.io/docs/api/). 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` <a href="#context-filesystem" id="context-filesystem"></a>

​[fs-extra](https://www.npmjs.com/package/fs-extra) npm package, which extends the native [fs API](https://nodejs.org/api/fs.html) in Node.js.

## `context.fileSystemJetpack` <a href="#context-filesystemjetpack" id="context-filesystemjetpack"></a>

​[fs-jetpack](https://www.npmjs.com/package/fs-jetpack) npm package. Some may prefer it over the native [fs API](https://nodejs.org/api/fs.html) in Node.js.

## `context.notifier` <a href="#context-notifier" id="context-notifier"></a>

​[node-notifier](https://www.npmjs.com/package/node-notifier) npm package. The main method in this class is `notify`.

### Example <a href="#example" id="example"></a>

```javascript
context.notifier.notify({  
    title: 'Notification Title',  
    message: 'This is an example notification message.',
});
```

## `context.process` <a href="#context-process" id="context-process"></a>

Node.js [process](https://nodejs.org/api/process.html) object.

## `context.React` <a href="#context-react" id="context-react"></a>

**Renderer Only**

`context.React` required to use JSX in your renderer entry point. You can also use `context.React` to access React's [Top-Level API](http://facebook.github.io/react/docs/top-level-api.html).

## `context.ReactRouter` <a href="#context-react" id="context-react"></a>

* `Link` - <https://reactrouter.com/web/api/Link>
* `NavLink` - <https://reactrouter.com/web/api/NavLink>
* `Route` - <https://reactrouter.com/web/api/Route>
* `Router` - <https://reactrouter.com/web/api/Router>

## Deprecated <a href="#context-docker" id="context-docker"></a>

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

## `context.request` <a href="#context-request" id="context-request"></a>

​[request](https://www.npmjs.com/package/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]\(<https://community.localwp.com/t/local-beta-8-0-0/39385>) release.

### `context.docker`

Use `context.docker` to run Docker commands.

#### Example

```javascript
context.docker(`start ${container}`).then(stdout => {    
    //Success
}).catch(({stdout, stderr}) => {    
    //Something bad happened
});
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://build.localwp.com/building/context-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
