Cross-device data sync in browser extension

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 Cross-device Sync in Browser Extension

Cross-device sync allows user's extension settings and data to follow them across all their devices where they're logged in with same Google/Microsoft account. This is automatic for chrome.storage.sync in Chrome, but requires explicit implementation in Firefox and Edge.

Chrome: automatic sync

chrome.storage.sync automatically syncs data across Chrome instances of same user:

// background.js
chrome.runtime.onInstalled.addListener(async () => {
  const defaults = {
    theme: 'system',
    highlightColor: '#fbbf24',
    shortcuts: {},
  };

  await chrome.storage.sync.set(defaults);
});

// Listen for sync changes
chrome.storage.onChanged.addListener((changes, area) => {
  if (area === 'sync') {
    // User signed in on another device and settings synced
    reloadUI();
  }
});

Limits: 100 KB total, 8 KB per key. Suitable for settings, not bulk data.

Firefox: manual sync via sync API

Firefox doesn't auto-sync storage.sync, but supports WebExtensions Sync:

// background.js
const SYNC_KEY = 'extensionSettings';

async function syncToRemote() {
  const settings = await browser.storage.local.get('settings');

  // Send to own server or cloud service
  await fetch('https://api.example.com/sync', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(settings)
  });
}

async function syncFromRemote() {
  const response = await fetch('https://api.example.com/sync');
  const remoteSettings = await response.json();

  await browser.storage.local.set(remoteSettings);
}

// Sync on install and periodically
browser.runtime.onInstalled.addListener(() => syncToRemote());
browser.alarms.create('sync-settings', { periodInMinutes: 60 });
browser.alarms.onAlarm.addListener((alarm) => {
  if (alarm.name === 'sync-settings') {
    syncFromRemote();
  }
});

Cross-browser sync architecture

Unified approach for Chrome, Firefox, Edge:

// shared/sync.ts
export interface SyncProvider {
  upload(data: Record<string, any>): Promise<void>;
  download(): Promise<Record<string, any>>;
}

export const chromeSync: SyncProvider = {
  async upload(data) {
    await chrome.storage.sync.set(data);
  },
  async download() {
    return await chrome.storage.sync.get(null) as Record<string, any>;
  }
};

export const remoteSync: SyncProvider = {
  async upload(data) {
    await fetch('/api/sync', {
      method: 'POST',
      body: JSON.stringify(data)
    });
  },
  async download() {
    const res = await fetch('/api/sync');
    return await res.json();
  }
};

// Select provider based on browser
export const syncProvider = isChromeOrEdge() ? chromeSync : remoteSync;

Timeline

Basic chrome.storage.sync: 1 day. Full cross-browser with remote server: 5–7 days.