Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

179
Visualizações
How to use IndexedDB from Chrome Extension Service Workers

I'm "happily" rebuilding some of my Chrome Extensions to MV3. But I'm stuck because I can't understand how to use IndexedDB from service workers. To be more specific, I haven't found any working example of IndexedDB access from a JS service worker script.

Referring to this page, I used to open a db like this:

var idb = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB || window.shimIndexedDB;
var dbName = "DatabaseName";
var open = idb.open(dbName, 1);

But as we all know, window is not accessible anymore from service workers in MV3.

To put it simply, background pages provide extension authors with an environment that lives independent of any other window or tab.

(https://developer.chrome.com/docs/extensions/mv3/migrating_to_service_workers/#state)

How am I supposed to do it?

Thanks for your help, time, and patience. Have a great weekend!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The answer is simpler than I thought. indexedDB is already defined when used in service workers and does not need to be related to the window object. It's ready-to-use.

var dbName = "DatabaseName";
var open = indexedDB.open(dbName, 1);

I'll leave this question in case someone else has the same doubt.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda