Shipping a web app as a Flutter app's UI, with signed over-the-air updates
I build for the web. Every time a product I worked on needed a phone app, the same two problems came back: the UI got written twice, and a one-word copy fix waited days for store review. Valence is the setup I wanted fo
I build for the web. Every time a product I worked on needed a phone app, the same two problems came back: the UI got written twice, and a one-word copy fix waited days for store review.
Valence is the setup I wanted for that: your existing web app becomes the UI of a small Flutter app, and UI changes ship over the air as signed bundles. It's open source (MIT) and the first public beta, 0.4.0-beta.1, is out now.
How it works
-
A small Flutter host ships through the stores once. It's a normal Flutter app that depends on the
valencepackage. Itsmain.dartis about twenty lines. - Your web app is the UI. SvelteKit, Vite, Astro or a Next.js static export, built to static files.
- Each release is a signed bundle. The CLI hashes every file, signs the manifest with an Ed25519 key, and you upload it to any static host.
- Each phone checks it before using it. It verifies the signature and every file's hash, serves the bundle to a WebView from a local loopback server, and runs it as a trial.
-
Bad releases roll themselves back. If the new UI doesn't call
ready()within its time limit twice, the phone marks it bad and goes back to the last good bundle. No server-side monitoring is involved.
The host side really is short:
Future<void> main() async {
final valence = await Valence.open(valenceConfig, hostBuild: 1);
final handlers = AppHandlers(valence);
runApp(MaterialApp(
home: ValenceApp(
valence: valence,
dispatch: (raw, nonce) => bridgeDispatch(handlers, raw, nonce: nonce),
),
));
}
A release is three commands:
npm run build # your web app, as usual
node valence/valence.mjs bundle # hash, sign, write the manifest
node valence/valence.mjs pointer --channel production --rollout 10
--rollout 10 sends it to 10% of phones first. You raise it to 50 and 100 by updating a small pointer file; nothing is re-signed.
Data that works offline
App data lives in SQLite on the phone, not in the WebView's storage. A first launch in airplane mode shows real content because the app ships with a seed. Writes go to an outbox and sync when the phone is back online, and reads sync incrementally ("everything after update #1234"). You bring your own backend and login; the host keeps the token in the Android Keystore.
The bridge between the page and the native side is generated from one schema file into both TypeScript and Dart, so the two sides can't drift apart. Add a method to the schema, run codegen, and the Dart analyzer tells you exactly which handler you still have to write.
Testing the docs like a stranger would
Before announcing it, I had two coding agents build a small offline grocery-list app overnight. Their only sources were the public docs and the published packages; reading the Valence source was off-limits. They logged every place they got stuck.
They found 14 problems. The worst: a brand-new project's first Android build failed with an error about flutter_local_notifications, a plugin the developer never added. Others were quieter, like a doctor check that asked for files the docs never mentioned, or a deep-link edge case where the Android back gesture leaves the app.
0.4.0-beta.1 fixes all of them, and re-running the same flow on a fresh project found three more, which are fixed too. That friction log turned out to be the most useful testing I've done.
What it isn't yet
- iOS is experimental and untested. Android is the supported platform.
- On Android, if the system kills the WebView's renderer under memory pressure, the app closes. Your data is safe, and the docs explain how to spot it, but it's a reason to start rollouts small.
- Store rules allow downloaded JavaScript that runs in a WebView as long as the app's purpose doesn't change. The docs quote the Apple and Google wording this relies on, but reviewers judge each app, so treat that as a reason for care, not a guarantee.
Try it
In your web project:
npm create valence@latest
Then follow the quick start. The code and the full spec are on GitHub.
If you try it, I'd like to hear where it got in your way. Those reports are what the next release is built from.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.