Search code examples
firebaseionic-frameworkfirebase-realtime-databaseionic4

How to fix import { Plugins } from '@capacitor/core'; Depricated Fix


Does anyone know what is the fix for the decricated import of ionic Plugins?

I'm following a tutorial and I cant proceed until I fix it..

import { Plugins } from '@capacitor/core';
import { Storage} = Plugins;

Many thanks


Solution

  • Do you mean what is the new way of importing plugins? I assume you mean previously we used to do something similar to:

    import { Plugins } from '@capacitor/core';
    import { MyImport } = Plugins;
    

    If that is the question you're asking, then Capacitor 3 now uses modulated plugins so they're all independent of each other.

    You now import them directly, e.g:

    import { Storage } from '@capacitor/storage';
    

    Available Capacitor plugins are here.

    Capacitor 4:

    Capacitor Storage has now been renamed to Preferences in Capacitor 4.

    So your new code would look like this:

    import { Preferences } from '@capacitor/preferences';