Skip to content

refactor(storage): replace @ionic/storage with @capacitor/preferences - #1900

Merged
gnbm merged 1 commit into
mainfrom
FW-6671
Nov 4, 2026
Merged

gnbm merged 1 commit into
mainfrom
FW-6671

Conversation

@gnbm

@gnbm gnbm commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does

This PR removes @ionic/storage and uses @capacitor/preferences instead.

The keys stay the same (ion_did_tutorial, hasLoggedIn, username), so the app logic does not change.
Only the place where the data is saved changes.

Why

  • With @ionic/storage, the data goes to IndexedDB and we need to call create() before reading it. Because of this, it was not possible to set the tutorial flag from a test in a reliable way.
  • This was the reason the tutorial e2e tests were flaky before they got removed in test(app): remove Cypress #1830.
  • @ionic/storage is also in the way for being deprecated, so this is suppose to replace it beforehand
  • With Capacitor Preferences, on the web the data is saved in localStorage and the read is simple and direct. A test can set the key and the app will see it every time.

Changes

  • Removed @ionic/storage, @ionic/storage-angular and the IonicStorageModule setup in main.ts.
  • Removed localforage from allowedCommonJsDependencies in angular.json, it was only needed by @ionic/storage.
  • user.service.ts, check-tutorial.guard.ts, tutorial.ts and app.component.ts now use Preferences.
  • Added unit tests for UserService and checkTutorialGuard, and updated the tests for the tutorial page and the app component.
  • Ran npx cap sync, so the ios/ and android/ folders have the new plugin.

Things to know

How I tested

  • npm run lint, npm run build -- --configuration=production and npm test -- --configuration=ci all pass.

Swap the Ionic Storage wrapper for Capacitor Preferences in the user
service, tutorial page, tutorial route guard and app component. Keys are
unchanged; booleans are now stored as the string 'true'. Drop the
IonicStorageModule bootstrap, the @ionic/storage packages and the
localforage CommonJS allow-list entry, and register the native plugin via
cap sync. Unit specs cover the login, tutorial and guard flows against
the real Preferences web implementation.

Closes FW-6671, relates to FW-6263.
@vercel

vercel Bot commented Nov 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ionic-conference-app Ready Ready Preview Nov 4, 2026 1:24pm UTC

Request Review

@gnbm
gnbm marked this pull request as ready for review November 4, 2026 14:04
@gnbm
gnbm requested a review from a team as a code owner November 4, 2026 14:04
@gnbm
gnbm requested review from ShaneK and brandyscarney and removed request for a team and brandyscarney November 4, 2026 14:04

@ShaneK ShaneK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@gnbm
gnbm merged commit 58a38e9 into main Nov 4, 2026
4 checks passed
@gnbm
gnbm deleted the FW-6671 branch November 4, 2026 20:15

This branch was successfully deployed

1 active deployment
Preview — 98217b53 Deployed Nov 4, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants