When you need to store things, you might put them in a box. Truck's Box does that for your app. It provides a consistent and simple interface for handling local data persistence using IndexedDB, WebSQL and localStorage. By default it tries to use IndexedDB. If the browser's implementation is buggy, Box will try to use WebSQL. If that also proves to be problematic, it will use localStorage.
All the latest versions of Safari, desktop and mobile, claim to support IndexedDB, in fact their implementation is seriously flawed, rendering this problematic for reliable storage. We therefore currently use WebSQL for Safari. Chrome and IE 10/MS Edge get IndexedDB. If you know what your target platform supports, you can tell Box to use it with a configuration setting to override the defaults.
Local data stores are not like server databases. They have severe limitations to how much data you can store. Box's data cap is 5MB. This is the limit for localStorage. If you want to ignore the localStorage fallback and depend on IndexedDB and WebSQL for your storage need, you can set the size to up to 50MB, which is the limit for WebSQL. Doing so means the user may be prompted to authorize it. Your users may not understand why they are being asked to permit storage and choose to deny it. You should therefore properly inform the user with a notification explaining that they need to authorize the use of more data for the app to function properly.
Although IndexedDB can store binary data, such as images, WebSQL and localStorage cannot. If you want to store binary data, Truck Box will need to encode the binary data in 64 bit format before saving. Depending on the size of your binary data, this may take quite some time. This will temporarily impact the performance of your app, so plan accordingly.