Skip to content

feat: Add in-memory fallback for localStorage collections in SSR environments - #696

Merged
KyleAMathews merged 5 commits into
mainfrom
claude/fallback-store-implementation-011CUK3giCpbGdRfgEUWSBwz
Oct 21, 2025
Merged

feat: Add in-memory fallback for localStorage collections in SSR environments#696
KyleAMathews merged 5 commits into
mainfrom
claude/fallback-store-implementation-011CUK3giCpbGdRfgEUWSBwz

Conversation

@KyleAMathews

Copy link
Copy Markdown
Collaborator

Prevents LocalStorageCollectionError when localStorage collections are imported on the server by automatically falling back to an in-memory store. This addresses issue #691 where importing client code with localStorage collections in server environments would throw errors during module initialization.

Changes:

  • Add createInMemoryStorage() to provide in-memory StorageApi fallback
  • Add createNoOpStorageEventApi() for server environments without window
  • Update localStorageCollectionOptions to use fallbacks instead of throwing errors
  • Remove unused NoStorageAvailableError and NoStorageEventApiError imports
  • Update tests to verify fallback behavior instead of expecting errors
  • Update JSDoc to document fallback behavior

This allows isomorphic JavaScript applications to safely import localStorage collection modules without errors, though data will not persist across reloads or sync across tabs when using the in-memory fallback.

Fixes #691

🤖 Generated with Claude Code

🎯 Changes

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • 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).

Loading
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.

Prevent "LocalStorageCollectionError" when local-storage collections are imported on the server

3 participants