samrum / vite-plugin-web-extension

A vite plugin for generating cross browser platform, ES module based web extensions.
MIT License
331 stars 32 forks source link

how to use browser.storage.sync in ContentScript #44

Closed AnweshGangula closed 2 years ago

AnweshGangula commented 2 years ago

Hi I'm trying to set the user preferences and saved them in storage. I would like to use storage.sync instead of storage.local.

But when I use browser.storage.sync.get, I get below error

Cannot read properties of undefined (reading 'sync')

How to solve this?

samrum commented 2 years ago

Not related to the plugin, but you'd need to declare the storage permission in your manifest to have access to the storage API.