# Problem with using Firebase in online P5 Editor

**URL:** <https://discourse.processing.org/t/problem-with-using-firebase-in-online-p5-editor/11642>\
**Category:** Libraries\
**Created:** [May 27, 2019, 8:25pm UTC](https://discourse.processing.org/t/problem-with-using-firebase-in-online-p5-editor/11642 "2019-05-27T20:25:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rsklarew](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/rsklarew/32/4956_2.png) [@rsklarew](https://discourse.processing.org/u/rsklarew)\
**Post date:** [May 27, 2019, 8:25pm UTC](https://discourse.processing.org/t/problem-with-using-firebase-in-online-p5-editor/11642/1 "2019-05-27T20:25:25Z")

</div>

Firebase realtime database works fine in the old offline P5 editor. But when I use the same code in the new online editor, the variable _firebase_ is not recognized:

```
       *"Uncaught ReferenceError: firebase is not defined (sketch: line 12)"*

```

The code is directly from _The Coding Train 9.2 “Firebase: Saving Data - Programming with Text”_ with the currently recommended Firebase source link added to the index:

```
         <script src="https://www.gstatic.com/firebasejs/6.0.2/firebase-app.js"></script>

```

and with account config removed from sketch.js:

```
function setup() {
  console.log("Setup");
  var firebaseConfig = {
    apiKey: "...",
    authDomain: "...",
    databaseURL: "...",
    projectId: "...",
    storageBucket: "...",
    messagingSenderId: "....",
    appId: "..."
  };
  firebase.initializeApp(firebaseConfig);
  console.log(firebase);
}

```

Again, it works fine in the old offline P5 editor but not in the new online one. Any suggestions appreciated so the online editor can be used to replace the old offline editor.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [June 1, 2019, 4:21pm UTC](https://discourse.processing.org/t/problem-with-using-firebase-in-online-p5-editor/11642/2 "2019-06-01T16:21:12Z")

</div>

Were you able to resolve this issue? I might start by checking existing public sketches on the web editor that contain “firebase” to see if any provide a good working model.

[https://www.google.com/search?q=“editor.p5js.org”+firebase](https://www.google.com/search?q=%22editor.p5js.org%22+firebase)

My main concern with this would be that API key privacy. The web editor doesn’t have a good privacy model yet – as far as I know.

---

<div class="post-metadata">

**Author:** ![rsklarew](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/rsklarew/32/4956_2.png) [@rsklarew](https://discourse.processing.org/u/rsklarew)\
**Post date:** [June 5, 2019, 6:37pm UTC](https://discourse.processing.org/t/problem-with-using-firebase-in-online-p5-editor/11642/3 "2019-06-05T18:37:00Z")

</div>

Yes, it was solved by replacing the firebase source in index.html with:  
`<script src="https://cdn.jsdelivr.net/npm/firebase@6.1.0/firebase.js"></script>`

Thanks for your suggestion.

---

<div class="post-metadata">

**Author:** ![Herby](https://avatars.discourse-cdn.com/v4/letter/h/e95f7d/32.png) [@Herby](https://discourse.processing.org/u/Herby)\
**Post date:** [December 17, 2019, 11:44am UTC](https://discourse.processing.org/t/problem-with-using-firebase-in-online-p5-editor/11642/4 "2019-12-17T11:44:52Z")

</div>

[rsklarew](https://discourse.processing.org/u/rsklarew) Thanks for posting your solution, it was great help.

(I adopted to the actual firebase version as well and it worked.)
