How to import @ionic/storage in Ionic Vue?

I would like to store some of my data but I can’t import it on ionic vue. I even tried to use vue session but I can’t use it in main.ts. Can anyone help me or share some wisdom?

it’s in the capacitor lib, from my app

import { Plugins } from "@capacitor/core";
const { Storage } = Plugins
1 Like

@ionic/storage is an Angular only package, so it cannot be used in a Vue app.

But as @sdetweil has suggested, Capacitor’s Storage API can be used instead.

2 Likes

You could also use the localForage library directly. Except for SQLite support, it’s what @ionic/storage uses under the hood. It prefers IndexedDB over localStorage if it’s available, which has a much larger quota compared to localStorage.

However, do note that IndexedDB and localStorage are prone to get purged without warning by the OS, as mentioned here.