3 ms·
Ask HN: How to create web, mobile, and desktop apps from a common code base?
I have an idea for a few apps that make sense to exist simultaneously as a web, mobile (Android and iOS), and desktop (Windows, Mac, and Linux) app. The research I have done so far is for utilizing JavaScript/TypeScript-based tech stack with React for the web, React Native for mobile, and Electron for desktop versions. Because I have yet not started learning those technologies I want to make sure that a common code base is achievable with them and also to consider some alternatives. For example, a commonly mentioned alternative of Electron is nw.js and I also found that React Native can be used not only for mobile but also for Desktop apps at least for Windows and MacOS.
What are your suggestions for a technological stack for the described cross-platform setting?
- mg 3y agoHave you considered making it a website? Then it can be used on every device via the browser.
- ibobev 3y agoOne of the versions will be a website, but I want mobile and desktop versions to be able to operate in offline mode with a local database.
- mg 3y agoHave you seen PWAs? https://www.google.com/search?q=pwa https://www.google.com/search?q=pwa Websites already have access to offline storage via the localStorage API. When the user installs a PWA, it gets additional permissions which make it even more similar to a native app.
- solardev 3y agoAs a web dev, I'd recommend against this. They have pretty shitty UX and always feel like second class citizens... If you want your users to be happy, make a proper app
- subtra3t 3y agoPlus, I'm pretty sure localStorage is limited to 5 MB of data.
- meiraleal 3y agoPWA tech has every building block needed to create a proper app besides the operator capable of creating the app
- solardev 3y agoThey load slow, have poor menu bars, don't use native UI widgets, have unclear update/versioning systems, can't be on all app stores, have inferior notifications, etc. How long have we been talking about them now as a replacement for native apps? I've still never seen one that's acceptable, much less equally good.
- meiraleal 3y agoPWAs can be published on all app stores and you probably used it without knowing. Not using native UI widgets isn't really a disadvantage, just an opinion. Well developed web apps are as good as native apps with better and worse things like everything that can be compared.
- catapart 3y agoSeconding the PWAs here, but I caution against thinking of it as an "either-or" situation. If you're going to build an app that can be accessed in a browser from a url, there are only benefits to making it a PWA. Offline, local capabilities, wider native device access, first-class icon placement with mobile apps, and the simplest distribution network ever invented. Absolute win to make your app a PWA. That said, it may lack some polish? I never had any issue with what they offered because I HATE apps. I will NEVER install an app on my device if I can help it. No facebook, no twitter, no amazon. If I should be able to do everything the app needs with a browser, then I will NOT download that app. Twitter and amazon at least understand that enough to have functional websites on all platforms. Things like facebook, on the other hand, are 'never installs' for me. So if there's something that capital-A Apps provide that you need, then you should probably go ahead and make one (hopefully using the same UI code you use for your PWA/web-app, but that's not always possible). Things like Twitch and YouTube get apps because they deal with a very specific type of data and can be (and are) optimized to handle that specific data type. Browsers just don't serve that kind of special-purpose design (nor should then), so there's valid reasons for those to be apps. On the other hand, if you can avoid making a single-purpose app, you should probably try it? Besides the wonks like me refusing app downloads, you also have the headache of maintenance for multiple platforms and all of that pretty much necessitates code mutations and generations for each specific platform that then each all need to be maintained (or worse, in-house developed and maintained). For all of the people out there pitching "holy grail" versions of the write-once, publish-everywhere mantra, I haven't found any that don't include some pretty fine text to the tune of "we use these specific processes and you've just gotta roll with that, even though they will probably cause you compatibility issues in your codebase at least once" As far as storage, though, localStorage is pretty sparse, it's true. But you can also use IndexedDB storage (pretty good!), and now there's a new file system api that mimics a disk file system in the browser, which is apparently way better but I don't have any first hand experience with that (and it's not useful to me until it can act like a database, but SQLite does seem to be working dilligently to make that happen ASAP). So there are options there, and while people may waffle about the reliability of some of them, I personally haven't run into any issues using IndexedDB (other than it's atrocious development experience).
- hotgeart 3y agoReact Native. Why would you want a desktop app when it's already working in a browser? If you really want a desktop app, I would recommend using React for the web, React with Electron for desktop, and React with CapacitorJS for mobile.
- ibobev 3y agoI want the mobile and desktop versions to be able to operate in offline mode with a local database.
- atomicnature 3y agoYou can use the React + (Browser, Capacitor, Electron) stack to do this. I'd recommend against React Native. OP's suggestion is superior IMHO.
- tzimo 3y agoYou could look into Flutter. It pretty much fits what you are looking for. I have tried it myself, but did not love it fwiw
- gardenhedge 3y agoFlutter is great for hybrid app development but I am not sold on the web part yet. That said, there is nothing that tackles iOS, Android and Web very well.
- ibobev 3y agoCould you recommend a good book or online learning resource for Flutter?
- sandreas 3y agoWork through the "Get started" section of the official docs[1]. After this you could take a look at Awesome Flutter[2]. If you are more into video tutorials, this one[3] is pretty compact but not made for total beginners. If you really want to get into it, you could now start checking out a not too big Open Source project like Musify (music player)[4], Localsend (file sharing)[5] or immich (photo sync)[6]. [1]: https://flutter.dev https://flutter.dev [2]: https://github.com/Solido/awesome-flutter https://github.com/Solido/awesome-flutter [3]: https://www.youtube.com/watch?v=D4nhaszNW4o https://www.youtube.com/watch?v=D4nhaszNW4o [4]: https://github.com/gokadzev/Musify https://github.com/gokadzev/Musify [5]: https://github.com/localsend/localsend https://github.com/localsend/localsend [6]: https://github.com/immich-app/immich/tree/main/mobile https://github.com/immich-app/immich/tree/main/mobile
- account-5 3y agoThis is what I went for after deciding against a web stack due to confusion over where even to start with it considering the ridiculous amount of competing frameworks. I also wanted a local first approach and didn't want to maintain a website. Happy with my choice though dart/flutter seem to be universally hated on HN.
- wizzerking 3y agoConsider .Net Core it requires c# but all the desktops and android are supported. I don't know about iOS
- neonsunset 3y agoiOS is supported even better than Android. You can experimentally build applications with NativeAOT for it and there's even native Swift interop[0] bypassing ObjC in the works (the motivation behind it is somewhat elusive to me but hey!) [0] https://github.com/dotnet/runtime/issues/93631 https://github.com/dotnet/runtime/issues/93631
- subtra3t 3y agoIs it .NET Core or just .NET? I think .NET Core was renamed to just .NET a while back but it's impossible to keep track of what's what after the many naming convention changes the team regularly makes.
- neonsunset 3y agoIt was renamed only twice. Once, after a clean break, rewrite and going open source, from .NET Framework to .NET Core. Then, from .NET Core to .NET to indicate a single platform going forward.
- sandreas 3y agoIn my opinion .NET is just not there yet. MAUI (the microsoft UI framework and Xamarin successor) does not support Linux or WASM and the main alternatives Uno Platform and Avalonia UI that do support Linux+WASM may be usable for smaller feature sets but as soon as it comes to more complex scenarios or library support, there is so much room for improvement. Furthermore, the deployment size of .NET is HUGE and NativeAOT is really hard to accomplish as soon as you have a few libraries. Startup times are also not that impressive and deploying for all platforms is really a pain. For comparison the size of a simple hello world Android App .NET > 70MB Flutter < 15MB That may sound like it's not relevant, but believe me, it is.
- mrKola 3y agoCompose multiplatform, and you will have a lot of fun.
- JaggerJo 3y ago.NET with C# / F# https://avaloniaui.net/ https://avaloniaui.net/
- stealthcat 3y agoKotlin multiplatform
- tomcam 3y agoLivecode
- atomicnature 3y agoI would recommend Capacitor JS for mobile, responsive CSS (or CSS utility libs such as PrimeCSS, PrimeFlex, or tailwind), and any JS state based library (React, Preact, etc). Many people underestimate the power of webview based tech in mobile. For most usecases, webview based tech does just fine.
- catapart 3y agoHighly recommend Tauri over Electron, if you are going to be using a web ui stack. Same kind of thing as Electron, just fresher so it's more streamlined (for now). It's Rust, but you can use extern libraries from most other languages, if you really need to. https://tauri.app/ https://tauri.app/
- max_ 3y agoFlutter would be the best. No one comes close to Android, iOS & Desktop support better than Flutter. Flutter also does support Web but has a few issues. But still I wou choose it.