Mobile: Native storage abstraction (Capacitor Preferences)#74
Merged
brianorwhatever merged 2 commits intomainfrom Feb 8, 2026
Merged
Mobile: Native storage abstraction (Capacitor Preferences)#74brianorwhatever merged 2 commits intomainfrom
brianorwhatever merged 2 commits intomainfrom
Conversation
- Install @capacitor/preferences package - Create storageAdapter.ts with unified async storage interface - Uses Capacitor Preferences on native platforms - Uses localStorage on web (wrapped in async API) - Add migration guide (STORAGE_MIGRATION.md) - Mark existing localStorage usage with TODO comments for future migration: - src/lib/storage.ts (settings functions) - src/hooks/useAuth.tsx (JWT and auth state) - src/lib/webvh.ts (private key storage) The storage adapter provides a foundation for native storage support without breaking existing synchronous code. Files can be migrated to use the async adapter incrementally.
b38a580 to
25544df
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR adds a native storage abstraction layer that provides a unified interface for both web and native platforms:
localStorage(synchronous)Changes
New Files
src/lib/storageAdapter.ts: Low-level async storage adapterWebStorage: Wraps localStorage in async API for webNativeStorage: Uses Capacitor Preferences on native platformsCapacitor.isNativePlatform()src/lib/STORAGE_MIGRATION.md: Migration guide and documentationModified Files
package.json: Added@capacitor/preferencesdependencysrc/lib/storage.ts: Added TODO comments for migrationsrc/hooks/useAuth.tsx: Added TODO comments for migrationsrc/lib/webvh.ts: Added TODO comments for migrationStrategy
Rather than breaking existing code, this PR:
localStorageusage with TODO commentsThis allows:
Testing
npm run build)Next Steps
Future PRs can migrate existing code incrementally:
storage.ts) - Most impactful, easiestwebvh.ts) - Security-criticaluseAuth.tsx) - Complex, needs careful testingBenefits