A thought occurred to me while checking Kartik Aga...
# thinking-together
x
A thought occurred to me while checking Kartik Agaram's post on #C03RR0W5DGC A Web page is a convenient medium to write a small application for yourself and distribute it. But it's also limiting, because of the browser. You can't easily edit local files, requests are limited by CORS, you can lose data if the browser's cache is emptied, etc. So I'm wondering: is there a sort of "browser for local apps", which would be just a webview with some of the browser's limitations lifted? For example, I could use Kartik's single-page app for annotating text, but instead of saving my changes by downloading the saved file, it would use the filesystem directly.
t
sounds like Electron
also https://redbean.dev/ actually
k
Redbean is a great example for technology that just lacks a good user interface for non-tech users. Imagine an Android app that would open a redbean file for editing, much like a .doc, and allow sharing (by mail or whatever other means). Plus the same for desktop. Unfortunately I suspect that at least Android creates a few obstacles to such an endeavor.
x
Yeah my only experience with Electron is in building stand-alone apps, I don't know if it's easy to use it as a generic "platform" that I could use to open small-apps Web pages.
Redbean's pretty cool! Thanks for sharing. It's not exactly what I have in mind, but it's interesting in its own right
m
I had to think about this: https://developer.chrome.com/docs/capabilities/web-apis/file-system-access .. not yet commonly available but this might be what you are looking for
a
I'm working on https://smallweb.run, which works like an "internet folder". Once you have it installed, you can create new websites by just creating a new folder and accessing it at
<folder-name>.smallweb.localhost
. Apps are able to write data to their own folder, that you can then reuse in any other apps. You can try it at https://demo.smallweb.live
x
The file system API would indeed be great for this. Maybe what I need is the browser 5 years from now 😛 I do feel like there's a tension in the design of the browser, between the traditional vision of browsing the Web, and the modern vision of using it for application distribution. I'm not sure how it will resolve over time.
a
Pwas are also quite neat. You can even integrate them with the native share sheet on android
x
Ah yeah true, I should look more into PWAs, it's not something I'm too familiar with as a dev.
Also, Smallweb is very cool, thanks for sharing!
a
Thanks! We also have a small community at https://discord.smallweb.run
(it's a smallweb app btw: https://gh.smallweb.run/discord/main.ts)
x
(I expected no less :D)
k
Are there any simple tools for developing simple PWAs ?
m
That's a nice use case for Cursor and see what it comes up with (I am playing around with cursor currently to see what it can help me create)
x
Do you have anything to share with Cursor regarding this already Maikel?
m
No not yet in regards to PWA, but the things that I have created are a basic but complete CRUD nextjs application including api (and database handling), authentication, styling. Also a synthetic data generation tool including data-type detection and various charts. Hopefully soon I'll show a "ghost text form control" that I am building with it for my own project. I am quite impressed with cursor so far. Not that it can do everything alone or that it's perfect. You still need to help it 😅
x
Cool, looking forward 🙂
a
https://val.town is a cool tool to build pwas. I've created this little middleware to convert any http val to a pwa: https://www.val.town/v/pomdtr/pwa, installable on ios / android
a
The last little app I made was with Vite/Svelte and used the filesystem API to save/open JSON files to persist the state. After you write a file, you get a handle that lets you keep writing to it as you make changes, so it works well for this. If I didn’t like Vite so much (which ships with a server), smallweb seems like it would be a good alt.
k
A bit of searching around revealed that PWAs are much less complicated than I expected. See e.g. this tutorial.
t
my slight complain about PWA is the manifest has to be connected via a relative link I think, which then mandates a websever. I would love to be able to install a service worker from a single file binary. Maybe it can be done via DataURL? I have not actually tried hacking that.
maybe it is possible? Someone was thinking the same thing here https://github.com/GoogleChromeLabs/pwacompat/issues/27
though service workers are themselves on the edge of portability and then adding a hack on top makes me thing you will not be able to rely on it, but in my mind is a value add anyway so you just gotta use them for optional extras (e.g. system notifications, home screen installation, app icon)
x
Ah I definitely need to do more things with Val. I didn't event think to try it to build little apps 🤔 The thing that stops me is that I'm a big fan of local-first, but maybe I can put that aside in order to experiment
a
I think the main thing that would stop you from building local first app on val.town is the lack of websocket support. But some libraries like https://tinybase.org/ would work just fine
j
I don't think browsers will ever be powerful enough for systems related stuff, for security reasons it'll always impose friction/limitations. Also I don't think using loopback network is ideal, it's a hack. Something like tauri, but leaner, just providing a native interface/wrapper to the OS own webview seems a more robust way to build and distribute html-based apps. Not sure what's the best cross-platform way to transact data between the webview process and the app's backend without serialization
For me the main advantage of electron over tauri is that you can stream files directly to the browser, you can just use local file paths, while with tauri you have to handle it yourself, it's very inneficient the last I tested
What we usually want from browsers for offline apps is the GUI engine, so there's the possibility of making and distributing a fork of it intended to be an app platform
I also think you could pioneer some kind of portable hardware like a mini computer intended to be used as a sidecar (using display and input interfaces from a laptop/pc) but with all the goodies to be used as an app platform
Could be as small as a thumb drive
To clarify the hardware product idea, imagine it's a headless system with built-in storage and compute, but more focused than a general purpose computer. You'd need drivers, and you could use the driver package to act as a worker of sorts
l
@Xavier Lambein ive been making lots of local-first things with valtown. its not one or the other
x
@Lu Wilson and so you use it to host code, and like store data in IndexedDB or automerge or something?
l
no i [just] use it for endpoints and store all the data locally too, usually localStorage. but the real thing that makes the difference is making it simple enough that other people can easily deploy and/or access it too. so that they don't rely on me or my hosting. eg https://logiverse.social some more examples at https://todepond.com/lab
x
ahh yeah that makes sense, thanks 🙂
m
there is also https://sciter.com/ (I have no experience with it)