tonis.dev
All writing
Writing

My phone can reach the dev server without my laptop

A paper phone connected by a folded ribbon to a server, with a closed laptop farther behind.

Introduction

I moved ClawTab's mobile development server to k3s. The development app on my phone can load its JavaScript from that server. My laptop no longer has to be the machine serving it.

I can follow coding agents through ClawTab when I'm away from the computer. Now I can also check the mobile development app without keeping a local Metro server running.

The native development app stays installed on the phone. The server sends it JavaScript. Changes to native dependencies still need a new phone build.

Keep the native build installed while updating JavaScript

ClawTab uses an Expo development build. Its native code and dependencies are installed on the phone. Metro, React Native's JavaScript bundler, serves the JavaScript.

I can keep the development build installed while changing screens, styles and other JavaScript or TypeScript code. Changes to native libraries or native configuration require rebuilding the app. Expo's development build documentation explains when to rebuild.

The diagram shows the two delivery paths. A native build installs the app; the shared server supplies its JavaScript while I'm developing.

Two paths reach an installed phone app: a native build is compiled and installed, while a public main checkout supplies JavaScript through Metro on k3s.
Metro serves JavaScript to the installed development app. Native dependencies reach the phone through a new build.

Run Metro on k3s

In my earlier networking setup, a Cloudflare Tunnel exposed a local Metro server. The computer running it had to stay on.

The shared setup runs Metro in my k3s cluster, with HTTPS and WebSockets routed through Traefik. The development app connects to that endpoint. The server keeps its own checkout and dependency cache on a persistent volume.

I use one Metro replica and one bundler worker. The container has a limit of one CPU and 5 GiB of memory.

This server is for development. App store releases are built separately.

A push to the public mobile repository updates the checkout

The server follows main in the public ClawTab repository. It polls every 30 seconds and updates its checkout when the branch moves. Metro then picks up the changed files.

For ordinary source changes, Metro keeps running and watches the updated files. With a connected app, Fast Refresh can update React components. Some changes cause a full reload or reset component state; React Native's Fast Refresh documentation explains those limits.

To check an agent's change through this endpoint, the change has to reach the public repository's main first. Local edits and other branches won't appear on the phone.

The table shows which path each kind of change takes.

Change What happens in this setup
Screen, style or other JavaScript source The server picks up the pushed revision; Metro watches the changed files.
Lockfile, package manifests, Metro/Babel or Expo configuration The update script installs dependencies and restarts its Metro process. Native configuration may also require a phone rebuild.
Native dependency or native app configuration I need a new compatible development build installed on the phone.
Git fetch fails The server keeps the current checkout and retries on the next interval.

The installed app has to support the JavaScript the server sends. If I add a native dependency, I need to install a new development build before testing code that uses it.

The endpoint serves one branch

There is one checkout behind the endpoint. Every connected phone gets the same branch. Agent worktrees don't get separate previews.

A preview for each branch would need its own checkout and a way to select the matching server. I can use local Metro with a separate endpoint to check a change before merging it.

For changes on main, I can check the development app from my phone without keeping Metro running on my laptop.

FAQ

Can I close my laptop and still load the development app?

Yes, when the installed development app connects to this shared Metro server. The server keeps its own checkout and dependency cache. It serves JavaScript independently of the laptop.

Which changes still require a new phone build?

Native dependencies and native app configuration need a new compatible development build. Screen, style and other JavaScript changes can come from Metro, although some changes cause a full reload or reset component state.

Can I preview an agent's unmerged branch on my phone?

This endpoint serves one checkout following the public repository's main branch. A separate branch preview needs another checkout and endpoint. Local edits in an agent's worktree won't appear through the shared endpoint.