Where is Storage and LocalStorage in rc0?

updated to the rc0
after all “fun” getting this

[15:26:04]  ngc error: Error: Error at /opt/git/ionic2/.tmp/providers/auth-service.ts:1:10: Module '"/opt/git/ionic2/node_modules/ionic-angular/index"' has no exported member 'Storage'.
Error at /opt/git/ionic2/.tmp/providers/auth-service.ts:1:19: Module '"/opt/git/ionic2/node_modules/ionic-angular/index"' has no exported member 'LocalStorage'.
➜  ionic2 git:(master) ✗ grep -r LocalStorage node_modules/ionic*|wc -l

how to work with localstorage now?

Storage has been removed from ionic-angular and into a separate module, @ionic/storage.

Have you installed @ionic/storage?

thank you for quick reply, will try it

Storage now exporting but LocalStorage doesn’t. What the name for it now?

yeah same problem here… really don’t hope they went and removed it that would suck!

LocalStorage seemed like a thin wrapper around LocalForage anyway. You could try using LocalForage directly.

thanks @rapropos,

do i just replace all LocalStorage with LocalForage??

I haven’t needed to do this yet, so I can’t say for sure. You will probably need to install @types/localforage and import localforage from 'localforage' at a minimum to get started.

1 Like

@rapropos you sir deserve a very cold and large beer!

Thanks it worked!

for @theromis heres what i did:

install it:

npm install @types/localforage npm install localforage

import it:

import * as localforage from "localforage";

and then change set, get remove, clear to their new values,


localforage.setItem('key', 'value' );

github: https://github.com/localForage/localForage
api doc: https://localforage.github.io/localForage/


Ionic Team is LocalStorage supported in RC0?

1 Like

I’m digging into this too. Actually there is no need to install localforage. Like @rapropos said, LocalStorage uses LocalForage.

I imported Storage from @ionic/storage and used the same way you are using localforage, but the syntax is a bit different. Instead of:

localforage.setItem('key', 'value' );


storage.set('key', 'value');

The same for getItem and get.


yeah saw that too.

but it’s either importing Storage or installing localforage.

Seeing as they dropped LocalStorage from ionic i believe it’s a safer bet to use localforage on its own… but thats just a personal choice.


when I do

 import * as localforage from "localforage";

[21:40:11] rollup: Export ‘config’ is not defined by …
[21:40:11] rollup: Export ‘setItem’ is not defined by …
[21:40:11] rollup: Export ‘getItem’ is not defined by …
[21:40:11] rollup: Export ‘clear’ is not defined by …

and when I do

import localforage from 'localforage';

I didn’t face error in the tray but it seems to didn’t work.

any idea?

1 Like

So I remember (now) that importing Localforage didn’t work, that’s why I used to have to set it as required, like this

declare let require: Function;

const localforage: LocalForage = require('localforage');

but when I do this, at runtime, I’ve got the error

file.js:11 Uncaught ReferenceError: require is not defined

any idea?

Got it (I like to answer my self :wink:

Import as to be done like following :slight_smile:

import localforage from 'localforage';

Important, when you use setItem and getItem don’t forget to add the type of the object to save!

   localforage.setItem<any>('key', object);

Of course replace with your type or let as you want.

Compilation is now ok, running with ionic serve is ok too and I confirm that in debug I see my informations into IndexedDB

P.S.: And for those who use localstorage

From release notes:

Storage has been removed from ionic-angular and placed into a separate module, @ionic/storage. Starters have been updated to add this, make sure to add it to your package.json if you’re using the storage system. See more details here.



This did not seem to work for me.

what’s the error you get?

I am getting the following error:

[03:04:28]  Error: Module c:\Projects\POC1\node_modules\localforage\dist\localforage.js does not export default (imported by c:\Projects\POC1\node_modules\@ionic\storage\es2015\storage.js)                                                          
    at Module.trace (C:\Projects\POC1\node_modules\rollup\dist\rollup.js:7677:29)                                          
    at ModuleScope.findDeclaration (C:\Projects\POC1\node_modules\rollup\dist\rollup.js:7300:22)                           
    at Scope.findDeclaration (C:\Projects\POC1\node_modules\rollup\dist\rollup.js:5351:39)                                 
    at Scope.findDeclaration (C:\Projects\POC1\node_modules\rollup\dist\rollup.js:5351:39)                                 
    at Identifier.bind (C:\Projects\POC1\node_modules\rollup\dist\rollup.js:6489:29)                                       
    at C:\Projects\POC1\node_modules\rollup\dist\rollup.js:5151:50                                                         
    at AssignmentExpression.eachChild (C:\Projects\POC1\node_modules\rollup\dist\rollup.js:5168:5)                         
    at AssignmentExpression.bind (C:\Projects\POC1\node_modules\rollup\dist\rollup.js:5151:7)                              
    at AssignmentExpression.bind (C:\Projects\POC1\node_modules\rollup\dist\rollup.js:5511:23)                             
    at C:\Projects\POC1\node_modules\rollup\dist\rollup.js:5151:50
1 Like

I may have gotten around this by adding this to a custom rollup config:

    include: {

Still have other issues so can’t confirm yet.