Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 212
Wesley Masunika Avatar asked Nov 04 '25 11:11

Wesley Masunika


1 Answers

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';
like image 108
Super_Simon Avatar answered Nov 06 '25 01:11

Super_Simon