# Where is Storage and LocalStorage in rc0?

**URL:** <https://forum.ionicframework.com/t/where-is-storage-and-localstorage-in-rc0/64886>\
**Category:** ionic-v3\
**Created:** [September 28, 2016, 10:40pm UTC](https://forum.ionicframework.com/t/where-is-storage-and-localstorage-in-rc0/64886 "2016-09-28T22:40:01Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![theromis](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/theromis/32/104314_2.png) [@theromis](https://forum.ionicframework.com/u/theromis)\
**Post date:** [September 28, 2016, 10:40pm UTC](https://forum.ionicframework.com/t/where-is-storage-and-localstorage-in-rc0/64886/1 "2016-09-28T22:40:01Z")

</div>

updated to the rc0  
after all “fun” getting this

```auto
[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'.

```

```auto
➜ ionic2 git:(master) ✗ grep -r LocalStorage node_modules/ionic*|wc -l
0

```

how to work with localstorage now?

---

<div class="post-metadata">

**Author:** ![niallr](https://avatars.discourse-cdn.com/v4/letter/n/839c29/32.png) [@niallr](https://forum.ionicframework.com/u/niallr)\
**Post date:** [September 28, 2016, 10:41pm UTC](https://forum.ionicframework.com/t/where-is-storage-and-localstorage-in-rc0/64886/2 "2016-09-28T22:41:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [September 28, 2016, 10:41pm UTC](https://forum.ionicframework.com/t/where-is-storage-and-localstorage-in-rc0/64886/3 "2016-09-28T22:41:26Z")

</div>

Have you installed `@ionic/storage`?

---

<div class="post-metadata">

**Author:** ![theromis](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/theromis/32/104314_2.png) [@theromis](https://forum.ionicframework.com/u/theromis)\
**Post date:** [September 28, 2016, 10:42pm UTC](https://forum.ionicframework.com/t/where-is-storage-and-localstorage-in-rc0/64886/4 "2016-09-28T22:42:28Z")

</div>

thank you for quick reply, will try it

---

<div class="post-metadata">

**Author:** ![theromis](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/theromis/32/104314_2.png) [@theromis](https://forum.ionicframework.com/u/theromis)\
**Post date:** [September 28, 2016, 10:46pm UTC](https://forum.ionicframework.com/t/where-is-storage-and-localstorage-in-rc0/64886/5 "2016-09-28T22:46:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![fishgrind](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/fishgrind/32/103232_2.png) [@fishgrind](https://forum.ionicframework.com/u/fishgrind)\
**Post date:** [September 28, 2016, 11:15pm UTC](https://forum.ionicframework.com/t/where-is-storage-and-localstorage-in-rc0/64886/6 "2016-09-28T23:15:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [September 28, 2016, 11:20pm UTC](https://forum.ionicframework.com/t/where-is-storage-and-localstorage-in-rc0/64886/7 "2016-09-28T23:20:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![fishgrind](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/fishgrind/32/103232_2.png) [@fishgrind](https://forum.ionicframework.com/u/fishgrind)\
**Post date:** [September 28, 2016, 11:22pm UTC](https://forum.ionicframework.com/t/where-is-storage-and-localstorage-in-rc0/64886/8 "2016-09-28T23:22:26Z")

</div>

thanks @rapropos,

do i just replace all LocalStorage with LocalForage??

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [September 28, 2016, 11:29pm UTC](https://forum.ionicframework.com/t/where-is-storage-and-localstorage-in-rc0/64886/9 "2016-09-28T23:29:45Z")

</div>

> [@fishgrind](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![fishgrind](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/fishgrind/32/103232_2.png) [@fishgrind](https://forum.ionicframework.com/u/fishgrind)\
**Post date:** [September 29, 2016, 12:03am UTC](https://forum.ionicframework.com/t/where-is-storage-and-localstorage-in-rc0/64886/10 "2016-09-29T00:03:42Z")

</div>

@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,

example:

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

github: [https://github.com/localForage/localForage](https://github.com/localForage/localForage)  
api doc: [https://localforage.github.io/localForage/](https://localforage.github.io/localForage/)

---

<div class="post-metadata">

**Author:** ![danielmm1997](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/danielmm1997/32/85966_2.png) [@danielmm1997](https://forum.ionicframework.com/u/danielmm1997)\
**Post date:** [September 29, 2016, 1:35am UTC](https://forum.ionicframework.com/t/where-is-storage-and-localstorage-in-rc0/64886/11 "2016-09-29T01:35:56Z")

</div>

Ionic Team is LocalStorage supported in RC0?

---

<div class="post-metadata">

**Author:** ![gasaki](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/gasaki/32/103462_2.png) [@gasaki](https://forum.ionicframework.com/u/gasaki)\
**Post date:** [September 29, 2016, 12:10pm UTC](https://forum.ionicframework.com/t/where-is-storage-and-localstorage-in-rc0/64886/12 "2016-09-29T12:10:48Z")

</div>

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' );`

use:

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

The same for getItem and get.

---

<div class="post-metadata">

**Author:** ![fishgrind](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/fishgrind/32/103232_2.png) [@fishgrind](https://forum.ionicframework.com/u/fishgrind)\
**Post date:** [September 29, 2016, 12:14pm UTC](https://forum.ionicframework.com/t/where-is-storage-and-localstorage-in-rc0/64886/13 "2016-09-29T12:14:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![reedrichards](https://avatars.discourse-cdn.com/v4/letter/r/34f0e0/32.png) [@reedrichards](https://forum.ionicframework.com/u/reedrichards)\
**Post date:** [September 29, 2016, 7:42pm UTC](https://forum.ionicframework.com/t/where-is-storage-and-localstorage-in-rc0/64886/14 "2016-09-29T19:42:27Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![reedrichards](https://avatars.discourse-cdn.com/v4/letter/r/34f0e0/32.png) [@reedrichards](https://forum.ionicframework.com/u/reedrichards)\
**Post date:** [September 30, 2016, 5:52am UTC](https://forum.ionicframework.com/t/where-is-storage-and-localstorage-in-rc0/64886/15 "2016-09-30T05:52:10Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![reedrichards](https://avatars.discourse-cdn.com/v4/letter/r/34f0e0/32.png) [@reedrichards](https://forum.ionicframework.com/u/reedrichards)\
**Post date:** [September 30, 2016, 5:58am UTC](https://forum.ionicframework.com/t/where-is-storage-and-localstorage-in-rc0/64886/16 "2016-09-30T05:58:53Z")

</div>

Got it (I like to answer my self 😉

Import as to be done like following 🙂

```
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);
   localforage.getItem<any>('key');

```

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.

=\>

```
 https://github.com/driftyco/ionic/blob/master/CHANGELOG.md#storage

```

---

<div class="post-metadata">

**Author:** ![gany](https://avatars.discourse-cdn.com/v4/letter/g/b2d939/32.png) [@gany](https://forum.ionicframework.com/u/gany)\
**Post date:** [October 2, 2016, 5:44am UTC](https://forum.ionicframework.com/t/where-is-storage-and-localstorage-in-rc0/64886/17 "2016-10-02T05:44:13Z")

</div>

This did not seem to work for me.

---

<div class="post-metadata">

**Author:** ![reedrichards](https://avatars.discourse-cdn.com/v4/letter/r/34f0e0/32.png) [@reedrichards](https://forum.ionicframework.com/u/reedrichards)\
**Post date:** [October 2, 2016, 7:09am UTC](https://forum.ionicframework.com/t/where-is-storage-and-localstorage-in-rc0/64886/18 "2016-10-02T07:09:42Z")

</div>

what’s the error you get?

---

<div class="post-metadata">

**Author:** ![alejandrocao](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/alejandrocao/32/101995_2.png) [@alejandrocao](https://forum.ionicframework.com/u/alejandrocao)\
**Post date:** [October 3, 2016, 6:07am UTC](https://forum.ionicframework.com/t/where-is-storage-and-localstorage-in-rc0/64886/19 "2016-10-03T06:07:24Z")

</div>

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
```

---

<div class="post-metadata">

**Author:** ![dsjgordon](https://avatars.discourse-cdn.com/v4/letter/d/9de0a6/32.png) [@dsjgordon](https://forum.ionicframework.com/u/dsjgordon)\
**Post date:** [October 3, 2016, 6:39am UTC](https://forum.ionicframework.com/t/where-is-storage-and-localstorage-in-rc0/64886/20 "2016-10-03T06:39:19Z")

</div>

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

```
plugins[
  commonjs({
    include: {
      'node_modules/localforage/**'
   }
 })
]

```

Still have other issues so can’t confirm yet.

[Next page](https://forum.ionicframework.com/t/where-is-storage-and-localstorage-in-rc0/64886.md?page=2)
