I want to build a browser extension that can read/write from the database that is behind my web app.

However, I don't really understand how that would work conceptually and what the best practices are? Should/can the extension communicate directly with the database? Is there some layer in between that I'm missing?

  • 2
    This is really broad... A good answer could fill an entire book. Can you make your question more specific? – Robert Harvey Jul 16 '18 at 18:06
  • Hi @RobertHarvey! The reason it's so broad is because I don't really know much about the topic to make it any more specific. I can try my best though. – Dynamic Jul 16 '18 at 18:07

A browser extension (web extension) is basically a web app where all the JS and other resources are already loaded in the browser. The functional difference to an ordinary website is that a web extension has has more privileges and has access to more browser APIs.

You use the same basic techniques to build web extensions that you'd use to build a (single page) web application. The web extension will communicate through normal HTTP requests with external services. If you want to access a database, the best practice is to build a backend server that exposes an API (usually in RESTful style). If you already have a web app, the web extension can likely reuse the same backend of the web app.

Note that thanks to advancements under the umbrella term “progressive web apps”, many features that would previously have required a privileged extension are also available to ordinary web apps, e.g. notifications, background processes, or persistent offline storage.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.