0

In my chrome extension, I have a global variable myVar in background.js which is not persistent when restarting the browser, e.g. not saved to extension storage. It works fine with mv2, but when it comes to mv3, I have to save it to extension storage because service workers are terminated when not in use and restarted when needed. However, I don't want to persist its value when the browser restarts. So my question is how can I detect browser restart so that I can remove myVar from extension storage?

herb
  • 139
  • 8
  • Use `chrome.storage.session` which is designed to replace global state ([example](https://stackoverflow.com/a/73090402)). – wOxxOm Dec 12 '22 at 08:58

1 Answers1

0

Thanks to wOxxOm, chrome.storage.session works.

herb
  • 139
  • 8