Browser extension data storage with chrome.storage

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.
Development and maintenance of all types of websites:
Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Our competencies:
Development stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1212
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    852
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    822
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    815

Implementation of Data Storage (chrome.storage) in Browser Extension

chrome.storage is the only reliable way to store data in extension. localStorage is technically available in popup and options page, but not in service worker, and doesn't sync between extension contexts. chrome.storage works everywhere.

Three storage types

chrome.storage.local — stored locally, up to 10 MB (without unlimitedStorage permission). Main choice for cached data, user content.

chrome.storage.sync — syncs across user's devices via Google account, up to 100 KB / 8 KB per key. For settings.

chrome.storage.session — memory only, cleared on browser close. In MV3 — for temporary SW state that survives its restart (unlike variables), but not browser restart.

Basic operations

// Write
await chrome.storage.local.set({
  userData: { id: 42, name: 'Alex' },
  lastFetch: Date.now(),
  items: [1, 2, 3]
});

// Read with defaults
const result = await chrome.storage.local.get({
  userData: null,
  lastFetch: 0,
  items: []
});
console.log(result.userData); // { id: 42, name: 'Alex' } or null

// Read by key
const { settings } = await chrome.storage.sync.get('settings');

// Delete
await chrome.storage.local.remove(['lastFetch', 'tmpData']);

// Clear all
await chrome.storage.local.clear();

Subscribe to changes

chrome.storage.onChanged.addListener((changes, areaName) => {
  if (areaName !== 'sync') return;

  if ('theme' in changes) {
    const { oldValue, newValue } = changes.theme;
    console.log(`Theme changed: ${oldValue} → ${newValue}`);
    applyTheme(newValue);
  }
});

This works in all extension contexts — content script also gets event if subscribed.

Typed storage wrapper utility

In real extension, convenient to make typed wrapper:

// storage/store.ts
type Settings = {
  theme: 'light' | 'dark' | 'system';
  targetLang: string;
  autoTranslate: boolean;
};

const defaultSettings: Settings = {
  theme: 'system',
  targetLang: 'en',
  autoTranslate: false,
};

export const settingsStore = {
  async get(): Promise<Settings> {
    const result = await chrome.storage.sync.get('settings');
    return { ...defaultSettings, ...result.settings };
  },

  async set(settings: Settings): Promise<void> {
    await chrome.storage.sync.set({ settings });
  },
};

Timeline

Simple get/set: 1 day. Complex store with listeners, migrations: 2–3 days.