Chapter 12. Storing app data

 

This chapter covers

  • Storing data in a variety of ways
  • Using the HTML5 localStorage API
  • Porting the TodoMVC project to run locally with NW.js and Electron

Applications need to store data; when you’re playing a game and loading from a saved level, or configuring settings for how you use a particular app, or even storing structured data in a line-of-business app, data must be stored somewhere and must be accessed by the app with ease.

Options for how to store data in your app range from using the HTML5 localStorage API to using embedded databases in your desktop app. In this chapter, we’ll explore some options and see how you can use them with your desktop apps.

12.1. What data storage option should I use?

In the old days, this was a simple question—there were fewer options. Traditionally, web apps relied solely on storing data in databases that lived on back-end servers. With the advent of client-side storage APIs for HTML5, the ability to store data on the client has resulted in the emergence of new libraries for that purpose, and for synchronizing that data with an external database.

Table 12.1 lists options for storing your data in web apps, and these can therefore be used in both Electron and NW.js apps.

12.2. Storing a sticky note with the localStorage API

12.3. Porting a to-do list web app

12.4. Summary

sitemap