https://blog.standardnotes.com/40921/no-react-native-is-not-the-future Listed Logo Privacy Matters HomeTry Standard NotesSubscribe HomeTry Standard NotesSubscribe No, React Native is not the future December 9, 2022*928 words Standard Notes has seen its codebase evolve many times through the years. When we first launched in late 2016, we started with three codebases: our web app (which our Electron desktop app contained), a native Swift iOS app, and a native Kotlin Android app. This was immediately untenable. Coordinating bug fixes across three platforms was hard enough, but building new features? Out of the question. We had to call our app "simple" because we literally couldn't make it anything else. (Tongue-in-cheek, but there's probably some truth to it.) From Three to Two Codebases In 2017 we transitioned to React Native for our mobile app, cutting down our total number of codebases to two. This felt like heaven, for a time. Now whenever we wanted to introduce a new feature, like encrypted images and files, we would need to write it "only" two times--what a fantastic, convenient arrangement, right? Utterly wrong. Sure, maximize your use of libraries and ensure you're not writing critical business logic twice. At some point however we reached the limit of that approach, having no choice but to write low-level streaming encryption functions for C because our web encryption library was not reusable on mobile. But even assuming you've maximized your usage of shared libraries, orchestrating features for two codebases with a small team is still a doubling of effort. Our mobile and web platforms had different issues and worked on different timelines. A bug that existed on mobile but not web which required two days to fix meant that web and mobile were constantly on different wavelengths. To then get the web and mobile teams to "sync up" to work on new features was a constant challenge. In addition, building on web was typically much faster than on mobile, so mobile was always behind. There is also no practical way to build on React Native without using a metric ton of third party libraries. Packages for React Native are their own special breed of monster because the package author would be the one writing code twice: once for iOS and once for Android (and of course the JavaScript wrapper). The result is a drastic increase in library abandonment and stability issues, on top of the already existing cons of relying on third party libraries. In addition, keeping your libraries in sync with your current version of React Native (which is notoriously difficult to keep up to date), was a nightmare of its own. At some point we had seen enough, and we begun to dream of a better world. It can't be like this. Two codebases--that's one too many. We started having fantasies of being able to write code only once. Imagine how fast we could ship. Imagine the developer productivity and happiness. Imagine dreaming of a feature, and not being let down because "ah, right, we'd have to write it for mobile too," and then abandoning that feature altogether due to the impracticality of doubling the effort. A single-codebase feature is effort enough. So we go to work on achieving the impossible. One Codebase To Rule Them All Only it turns out, it wasn't so impossible. When we finished the transition, we asked ourselves why we hadn't done this sooner. Today, Standard Notes is just 1 codebase. Our mobile app is just our web app with access to native mobile functionality, and it runs like a dream. It features 1:1 feature parity with our desktop app, which was impossible with our old application. It accesses the native mobile keychain, biometrics, local storage, camera, and more. Mobile app collage How did we do it? Quite simple really: a bridge between web-land and mobile native-land. Our new mobile app still uses React Native, but is literally just 1 component: a function that renders a webview. The webview facilitates message passing between web-land and native-land through a postMessage bridge. When web-land wants to access the device keychain, it sends a message to native-land, and native-land responds with a primitive value. Neither native-land or web-land ever have to think about "messages" though. They're just function calls. Web-land has no idea that its function calls are being converted to postMessage calls behind the scenes. Web is also using await for a response just like it would any other async function. This is not meant to be a technical post, but at a high level, our architecture consists of each platform simply having to provide a "device interface" to an Application instance, and with that interface, an application can run on any platform, even a command line. The device interface provides access to device APIs, like the database, keychain, or camera. A better way to build mobile Don't get me wrong: there's a lot to love about React Native. Its community and package ecosystem are vibrant, probably more so than many similar libraries. But if too you're finding that two codebases is one too many, it doesn't have to be like this. You don't have to rewrite your web application UI from scratch into React Native. Instead, just use RN as the bridge to access native system functionality from your web app core. Your users won't be able to tell the difference. In our case, our new mobile app is, in our estimation, 10x better than our old, perpetually lagging-behind app. Try it for yourself. If you're starting today, you can take a similar approach to ours, or take a look at libraries like Capacitor which do something very similar, with the downsides of not having the same rich third-party package ecosystem as React Native. --------------------------------------------------------------------- Subscribe to the author's posts You'll only receive email when they publish something new. [ ]Subscribe More from Privacy Matters All posts Introducing Super notes, Moments, and offline file access December 2, 2022*701 words We're excited to announce the release of some great new features for Standard Notes, the private and encrypted note-taking app. These features will help you create, organize, and view your notes more intuitively and allow you to create fine-grained and powerful organizational structures. The first new feature is Super notes, which is a new way to edit notes. Use the / key to bring up the block selection menu, or the @ key to embed images or link other tags and notes. You can also type - then sp... Read post New Wave: Second Brain Note-Taking December 19, 2022*212 words As a company that provides a simple and secure note-taking app, Standard Notes has often been lumped in with the various "second brain" or productivity tools that have become popular in recent years. While these tools can certainly be useful for some people, we have always taken a different approach. As we tweeted recently, we believe that our job is to get out of your way so you can do your job. We don't provide any flashy or self-aggrandizing features like a "graph view" or promises of "disco... Read post Listed Blogging Platform Copyright (c) 2022 Privacy Matters Via Standard Notes