diff --git a/src/gatsby-browser.js b/src/gatsby-browser.js
index <HASH>..<HASH> 100644
--- a/src/gatsby-browser.js
+++ b/src/gatsby-browser.js
@@ -7,7 +7,8 @@ exports.onClientEntry = (
     { languages, filename = "search_index.json" }
 ) => {
     enhanceLunr(lunr, languages);
-    fetch(`${__PATH_PREFIX__}/${filename}`)
+    window.__LUNR__ = window.__LUNR__ || {};
+    window.__LUNR__.__loaded = fetch(`${__PATH_PREFIX__}/${filename}`)
         .then(function(response) {
             return response.json();
         })
@@ -20,8 +21,14 @@ exports.onClientEntry = (
                         store: fullIndex[key].store
                     }
                 }),
-                {}
+                {
+                    __loaded: window.__LUNR__.__loaded
+                }
             );
+            return window.__LUNR__;
         })
-        .catch(e => console.log("Failed fetch search index"));
+        .catch(e => {
+            console.log("Failed fetch search index");
+            throw e;
+        });
 };
Provide Promise-based hook for when lunr is loaded (#<I>)

* Provide Promise-based hook for when lunr is loaded



Fixes #<I>



Enables code like so on the client, which resolves the issue of first page loads not being able to access `window.__LUNR_`



```

window.__LUNR__.loaded.then(lunr => {

  // Do lunr search here

});

```



* Simplify loaded hook