What databases can an addon use?

I want to create my first Firefox addon to collect browsing history for a specific website, store it in a database, and then mark the content that’s already been viewed for that particular website every time i revisit it. I want to store the data indefinitely or at least export it to different computers - maybe sync it between different machines if that’s possible.

I’m a little confused about which database i can use and is best suited for my addon. I read that indexdb allows a user to visit the settings and clear the data stored. Is addon storage just a directory where an addon can store data or is it a db? And i’ve seen examples using regular sqlite databases within a browser profile.

May someone point me in the right direction please? What database should i use?

Thanks

See the docs:

Basically these are your options:

  • storage.local - often the best option, it’s fast, reliable and can store 5MB of data or unlimited if you use “unlimitedStorage” permission
  • storage.sync - can be used to sync data between devices, but can store only 100KB and each key can store only 8KB
  • IndexedDB - less stable, there are some rare cases when it gets broken. Also it “suffers” from same origin policy, so private tab or container can’t access the same database, you will have to ask your background script to fetch data. But it’s also super fast, allows database-like access and can store Blobs! Also it’s almost unlimited even without a special permission.

None of these are clearable by user (AFAK).

You can also zip your data to save some space, but you will need a zip library, for example lzutf8.

You can explore how your current extensions’ local storage is persisted to disk. First you’ll need to look up the extension’s UUID on the about:debugging page, This Firefox panel.

Then in your currently active Firefox profile folder, open the storage folder, then the default folder. Look for the extension’s folder, named along the lines of

moz-extension+++ UUID

Inside that folder, look for an idb folder

The idb folder should contain one or more SQLite databases. If you open one in a SQLite database browser, you will find that the data in the object store is compressed. This is not encryption, but does make casual examination of the data very difficult.