{"id":2708,"date":"2026-06-15T23:29:37","date_gmt":"2026-06-15T23:29:37","guid":{"rendered":"https:\/\/localwp.com\/?p=2708&#038;post_type=help&#038;preview_id=2708"},"modified":"2026-06-25T08:36:29","modified_gmt":"2026-06-25T08:36:29","slug":"context-api","status":"publish","type":"help","link":"https:\/\/localwp.com\/help-docs\/building-your-add-on\/context-api\/","title":{"rendered":"Context API"},"content":{"rendered":"\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color wp-elements-13f04276d875d49607e7ae200be8065f\" style=\"color:#000000\"><code><strong>context.environment<\/strong><\/code><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Includes the following properties:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>appPath:<\/strong> Path to running Local by Flywheel.app<\/li>\n\n\n\n<li><strong>userHome:<\/strong> Path to current user home directory<\/li>\n\n\n\n<li><strong>phpVersion:<\/strong> Available PHP versions in Local<\/li>\n\n\n\n<li><strong>version:<\/strong> Local version<\/li>\n\n\n\n<li><strong>dockerPath:<\/strong> Path to Docker binary in Local by Flywheel.app<\/li>\n\n\n\n<li><strong>userDataPath:<\/strong> Path to Local&#8217;s user data folder. On macOS this defaults to <code>~\/Library\/Application Support\/Local by Flywheel<\/code><\/li>\n<\/ul>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color wp-elements-de1986f199ebea3cefbc2d8e39a20927\" style=\"color:#000000\"><strong><code>context.hooks<\/code> <\/strong><a href=\"#context-hooks\" id=\"context-hooks\"><\/a><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Use <code>context.hooks<\/code> to run actions at certain times. Hooks are especially useful when adding in element with <code>context.React<\/code>.<\/p>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color wp-elements-ea907d797a1920bb1115102ff9031af1\" style=\"color:#000000\"><strong><code>context.electron <\/code><\/strong><a href=\"#context-electron\" id=\"context-electron\"><\/a><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Exposes <a href=\"http:\/\/electron.atom.io\/docs\/api\/\"><strong>Electron API<\/strong><\/a>. The available methods and classes will differ based on whether or not this is ran from the main process or renderer process.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">With the Electron API you can create dialogs, open new windows, and more.<\/p>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color wp-elements-b8fb3818c890516c9e77c7853fe44602\" style=\"color:#000000\"><strong><code>context.fileSystem <\/code><\/strong><a href=\"#context-filesystem\" id=\"context-filesystem\"><\/a><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u200b<a href=\"https:\/\/www.npmjs.com\/package\/fs-extra\"><strong>fs-extra<\/strong><\/a> npm package, which extends the native <a href=\"https:\/\/nodejs.org\/api\/fs.html\"><strong>fs API<\/strong><\/a> in Node.js.<\/p>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color wp-elements-72c60fe17cb56249fdf7cb8e1876b672\" style=\"color:#000000\"><strong><code>context.fileSystemJetpack <\/code><\/strong><a href=\"#context-filesystemjetpack\" id=\"context-filesystemjetpack\"><\/a><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u200b<a href=\"https:\/\/www.npmjs.com\/package\/fs-jetpack\">f<strong>s-jetpack<\/strong><\/a> npm package. Some may prefer it over the native <a href=\"https:\/\/nodejs.org\/api\/fs.html\"><strong>fs API<\/strong><\/a> in Node.js.<\/p>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color wp-elements-29e83521adbceaf650a1097c6509b9d4\" style=\"color:#000000\"><strong><code>context.notifier <\/code><\/strong><a href=\"#context-notifier\" id=\"context-notifier\"><\/a><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u200b<a href=\"https:\/\/www.npmjs.com\/package\/node-notifier\"><strong>node-notifier<\/strong><\/a> npm package. The main method in this class is <code>notify<\/code>.<\/p>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color wp-elements-a965665a62a4a832e7dca8295e1526c4\" style=\"color:#000000\"><strong>Example <\/strong><\/h3>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism off-numbers lang-js\" data-lang=\"JavaScript\" data-show-lang=\"1\"><code>context.notifier.notify({  \n    title: &#39;Notification Title&#39;,  \n    message: &#39;This is an example notification message.&#39;,\n});<\/code><\/pre><\/div>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color wp-elements-473bda63a3d6bc1d0463ee7536a73249\" style=\"color:#000000\"><strong><code>context.process <\/code><\/strong><a href=\"#context-process\" id=\"context-process\"><\/a><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Node.js <a href=\"https:\/\/nodejs.org\/api\/process.html\"><strong>process<\/strong><\/a> object.<\/p>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color wp-elements-e551d65fa37f4a10dcffcccfe7224f35\" style=\"color:#000000\"><strong><code>context.React <\/code><\/strong><a href=\"#context-react\" id=\"context-react\"><\/a><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Renderer Only<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>context.React<\/code> required to use JSX in your renderer entry point. You can also use <code>context.React<\/code> to access React&#8217;s <a href=\"http:\/\/facebook.github.io\/react\/docs\/top-level-api.html\"><strong>Top-Le<\/strong>vel API<\/a>.<\/p>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color wp-elements-c44dceec68bb3e2fc0889e0610f7d1d1\" style=\"color:#000000\"><strong><code>context.ReactRouter <\/code><\/strong><a href=\"#context-react\" id=\"context-react\"><\/a><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>Link<\/code> &#8211; <a href=\"https:\/\/reactrouter.com\/web\/api\/Link\"><strong>https:\/\/reactrouter.com\/web\/api\/Link<\/strong><\/a><\/li>\n\n\n\n<li><code>NavLink<\/code> &#8211; <a href=\"https:\/\/reactrouter.com\/web\/api\/NavLink\"><strong>https:\/\/reactrouter.com\/web\/api\/NavLink<\/strong><\/a><\/li>\n\n\n\n<li><code>Route<\/code> &#8211; <a href=\"https:\/\/reactrouter.com\/web\/api\/Route\"><strong>https:\/\/reactrouter.com\/web\/api\/Route<\/strong><\/a><\/li>\n\n\n\n<li><code>Router<\/code> &#8211; <a href=\"https:\/\/reactrouter.com\/web\/api\/Router\"><strong>https:\/\/reactrouter.com\/web\/api\/Router<\/strong><\/a><\/li>\n<\/ul>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color wp-elements-c333e87bee7557a38f0d3055273df4fb\" style=\"color:#000000\"><strong>Deprecated <\/strong><a href=\"#context-docker\" id=\"context-docker\"><\/a><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The following contexts have been deprecated in the most recent versions of Local.<\/p>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color wp-elements-4015e6d5a4edcf326e9f6b6b27240646\" style=\"color:#000000\"><strong><code>context.request<\/code> <\/strong><a href=\"#context-request\" id=\"context-request\"><\/a><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u200b<a href=\"https:\/\/www.npmjs.com\/package\/request\">request<\/a><\/strong> npm package, which makes it very easy to send HTTP\/HTTPS requests.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The request package was deprecated on Feb 11th 2020, and removed from Local in the [v8.0.0](<a href=\"https:\/\/community.localwp.com\/t\/local-beta-8-0-0\/39385\"><strong>https:\/\/community.localwp.com\/t\/local-beta-8-0-0\/39385<\/strong><\/a>) release.<\/p>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color wp-elements-1b3f34154735d7aa9be4d4abf9494707\" style=\"color:#000000\"><code><strong>context.docker<\/strong><\/code><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Use <code>context.docker<\/code> to run Docker commands.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color wp-elements-370e58fec21ff6807317b7f728f62848\" style=\"color:#000000\"><strong>Example<\/strong><\/h3>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism off-numbers lang-js\" data-lang=\"JavaScript\" data-show-lang=\"0\"><code>context.docker(`start ${container}`).then(stdout =&gt; {    \n    \/\/Success\n}).catch(({stdout, stderr}) =&gt; {    \n    \/\/Something bad happened\n});<\/code><\/pre><\/div>\n\n\n\n<div style=\"height:90px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>context.environment Includes the following properties: 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 Electron 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&#8230;<\/p>\n","protected":false},"author":78,"parent":2696,"menu_order":2,"template":"","tags":[],"helpcategories":[69],"class_list":["post-2708","help","type-help","status-publish","hentry","helpcategories-building-your-add-on"],"acf":{"help_keywords":""},"_links":{"self":[{"href":"https:\/\/localwp.com\/wp-json\/wp\/v2\/help-doc\/2708","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/localwp.com\/wp-json\/wp\/v2\/help-doc"}],"about":[{"href":"https:\/\/localwp.com\/wp-json\/wp\/v2\/types\/help"}],"author":[{"embeddable":true,"href":"https:\/\/localwp.com\/wp-json\/wp\/v2\/users\/78"}],"version-history":[{"count":0,"href":"https:\/\/localwp.com\/wp-json\/wp\/v2\/help-doc\/2708\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/localwp.com\/wp-json\/wp\/v2\/help-doc\/2696"}],"wp:attachment":[{"href":"https:\/\/localwp.com\/wp-json\/wp\/v2\/media?parent=2708"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/localwp.com\/wp-json\/wp\/v2\/tags?post=2708"},{"taxonomy":"helpcategories","embeddable":true,"href":"https:\/\/localwp.com\/wp-json\/wp\/v2\/helpcategories?post=2708"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}