Ionic adds a new State feature

This post is more than 2 years old.

To be fair, this may not be very new, I've been working with an alpha version of the Ionic CLI while I test push (and other stuff ;) so my version has been a bit out of sync. Today I switched from the alpha to the release version and discovered a cool new feature - State.

The State feature lets you quickly save and restore plugins and platforms for an Ionic project. By default, when you add a platform or a plugin, Ionic will store this information in the package.json file. Here is an example of adding a platform:


(And as an aside - did you notice it added icons and splashscreens? Freaking awesome.) And here is adding a new plugin:


When done, here is how package.json is updated:

  "name": "apr20-2",
  "version": "1.0.0",
  "description": "apr20-2: An Ionic project",
  "dependencies": {
    "gulp": "^3.5.6",
    "gulp-sass": "^1.3.3",
    "gulp-concat": "^2.2.0",
    "gulp-minify-css": "^0.3.0",
    "gulp-rename": "^1.2.0"
  "devDependencies": {
    "bower": "^1.3.3",
    "gulp-util": "^2.2.14",
    "shelljs": "^0.3.0"
  "cordovaPlugins": [
  "cordovaPlatforms": [

To skip this, you can use --nosave for both platform and plugin modifications. Now comes the cool part. To quickly load in plugins and platforms, you can simply do:

ionic state restore

And Ionic will add in the appropriate plugins and platforms. This will be incredibly useful for folks checking out your Ionic project from a source control repository.

You can also do:

ionic state save

To store the current platforms and plugins to the package.json. I would imagine you would use this feature if you used the --nosave option to test a plugin you weren't sure you wanted to actually keep around.

You may want to remove everything. You can do this with:

ionic state clear

But be aware this really, really does remove everything, including the default plugins Ionic always install. Finally, you can do:

ionic state reset

This will remove everything then bring back what you have specified in the package.json file.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate for HERE Technologies. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA