Skip to content

Conversation

@TomasGonzalez
Copy link

🎯 Changes

Add offline persistence adapter for Electric collections
This PR introduces a localStorage-based persistence layer for Electric collections, enabling offline-first data access and faster initial loads.

Key features:

  • Persist synced data locally: Collection data is automatically saved to localStorage as it syncs, configurable via persistence.storageKey

  • Restore on startup: Persisted data is loaded into the collection on initialization, making data available immediately without waiting for network

  • Resumable sync: Shape handle and last offset are persisted, allowing sync to resume from where it left off

Use case: This enables offline-first apps where users can see their data immediately on app launch, even before the network sync completes.

Configuration:

  electricCollectionOptions({
    id: 'my-collection',
    syncMode: 'on-demand',
    persistence: {
      storageKey: 'my-collection-storage',
    },
    // ... other options
  })

✅ Checklist

  • (not found) I have followed the steps in the Contributing guide. (not found)
  • I have tested this code locally with pnpm test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

@changeset-bot
Copy link

changeset-bot bot commented Dec 2, 2025

🦋 Changeset detected

Latest commit: e550691

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@tanstack/electric-db-collection Minor
@tanstack/db-collection-e2e Patch
@tanstack/db-example-solid-todo Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant