Since launching last year, we’ve received a steady stream of feedback from developers asking to use Firebase in their Chrome extensions. A Chrome extension is actually a perfect candidate for Firebase, since unlike a traditional web app, you don’t even need a server to host your HTML and JavaScript. The entire app lives in the browser.
This browser-hosted app model is great if your app lives in isolation, but what if you want to store and retrieve data outside of your extension? Or perhaps let users of your extension collaborate with one another?
As of today, you can use Firebase! We’ve updated Firebase to work even in the limited execution environment that Chrome extensions run in.
To get started, we have a sample extension on github you can fork. Or you can create your own extension from scratch and add the following snippet to your manifest.json
to allow your extension to access Firebase:
"content_security_policy": "script-src 'self' https://cdn.firebase.com
https://*.firebaseio.com; object-src 'self'"
Once you’ve added that snippet, you can include firebase.js in any extension page, background page, or content script, and use the JavaScript API just as you would use it in any other web app.
We look forward to seeing your Firebase-powered Chrome Extensions — happy hacking!