0Pricing
Browser Extensions Development (Chrome & Edge) · Lesson

Sync vs Local Storage & Quotas

Choose the right Chrome storage area, understand quota limits, and handle storage change events reliably.

Sync vs Local Storage & Quotas is a free Browser Extensions Development (Chrome & Edge) lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Browser Extensions Development (Chrome & Edge) learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Two Main Storage Areas

The Chrome storage API offers several areas. The two you use most are storage.local and storage.sync.

  • local — stays on this device, larger quota
  • sync — syncs across the user's signed-in browsers, smaller quota

When to Use sync

Use storage.sync for user preferences you want to follow them everywhere, like theme or settings. Keep the data small.

chrome.storage.sync.set({ theme: 'dark', fontSize: 14 })

When to Use local

Use storage.local for larger or device-specific data such as caches, logs, or downloaded content that does not need to sync.

chrome.storage.local.set({ cache: bigObject })

Sync Quota Limits

storage.sync is intentionally small. Roughly: about 100 KB total, 8 KB per item, and a limited number of writes per minute.

Exceeding these throws errors, so plan your data shape.

// Stay well under ~8 KB per key for sync

Local Quota Limits

storage.local allows far more, commonly around 10 MB by default, and the unlimitedStorage permission can raise it. Still avoid storing huge blobs.

{
  "permissions": ["storage", "unlimitedStorage"]
}

Reading Data Back

Both areas read with get. Pass a key, an array of keys, or an object of defaults.

const data = await chrome.storage.sync.get({ theme: 'light' })
console.log(data.theme)

Watching for Changes

The onChanged event fires whenever stored values change, even from another context. Use it to keep your UI in sync.

chrome.storage.onChanged.addListener((changes, area) => {
  if (area === 'sync' && changes.theme) {
    console.log('New theme: ' + changes.theme.newValue)
  }
})

Removing and Clearing

Delete specific keys with remove, or wipe an entire area with clear.

chrome.storage.local.remove('cache')
chrome.storage.sync.clear()

Checking Bytes Used

Use getBytesInUse to see how close you are to the quota before writing more data.

const used = await chrome.storage.sync.getBytesInUse()
console.log(used + ' bytes used')

Handling Write Failures

Sync writes can fail on quota errors. Wrap writes in try/catch and fall back to local storage when sync is full.

try {
  await chrome.storage.sync.set({ big: value })
} catch (e) {
  await chrome.storage.local.set({ big: value })
}

Choosing Wisely

A common pattern: keep small settings in sync, keep everything else in local. Never store secrets like tokens in plain storage, since extension storage is not encrypted.

Quick Check

Test your storage knowledge.

Recap

You compared storage areas:

  • sync for small cross-device settings
  • local for larger device data
  • Respect quotas and check getBytesInUse
  • React to onChanged
  • Handle write failures and avoid storing secrets

Picking the right area keeps your data fast, durable, and within limits.

Frequently asked questions

Is the “Sync vs Local Storage & Quotas” lesson free?

Yes — the full text of “Sync vs Local Storage & Quotas” is free to read here on the web, and the Browser Extensions Development (Chrome & Edge) course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Browser Extensions Development (Chrome & Edge) course, upgrade to CoddyKit PRO.

What will I learn in “Sync vs Local Storage & Quotas”?

Choose the right Chrome storage area, understand quota limits, and handle storage change events reliably. You practise Browser Extensions Development (Chrome & Edge) with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Browser Extensions Development (Chrome & Edge)?

No prior experience is required. Browser Extensions Development (Chrome & Edge) on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Sync vs Local Storage & Quotas” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Browser Extensions Development (Chrome & Edge) lesson?

Yes. Every Browser Extensions Development (Chrome & Edge) lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. One-Way Messaging Patterns
  2. Two-Way Messaging Between Components
  3. Using Chrome Storage API
  4. Sync vs Local Storage & Quotas
← Back to Browser Extensions Development (Chrome & Edge)