![]() I created a basic List app using the approach outlined below so I could share a working example of these concepts (and code) in action. For example, if data must be shared with other users of the app, an approach involving a centralized database service is likely more appropriate. It’s worth noting that this approach will not work for every app. Looking for steps to bootstrap an app like this? Take 10 minutes and work through the official docs on the subject first: Using TypeScript with React Native. Let’s begin by adding the native SQLite bits to an existing React Native app (RN going forward) that’s built with the excellent combo of TypeScript and CocoaPods. It’s fast, rock solid, and has been battle tested for years across a huge array of platforms and devices. When it comes to storing relational data on-device with minimal overhead, SQLite is the natural choice. If your users’ wish to sync their data with another device, the app can be integrated with a service like Dropbox (a pattern I’ve seen work well in other apps, such as pre-version 7 1Password). ![]() The app will work offline without any extra effort, since the entire datastore will be contained in the app’s sandbox directory.No server-side code to develop, debug, load test, and monitor.There’s no server for you to manage, patch, keep online, and serve as a single point of failure for your app.Why might you pursue building an offline first app with an integrated database? This article walks through how I built an offline first React Native app using a device-local SQLite database, and details the patterns that I would recommend following when building your own. The text has been condensed too because man did I ever ramble on back then □. The code and content has been given a complete overhaul for 2020 to feature Hooks, Context, and updated to use React Native 0.61.5. What follows is a refresh of my most-read post, originally published in 2018. Building an offline first app with React Native and SQLite: 2020 refresh May 3, 2020, by Bruce Lefebvre
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |