Open History to see the last commit
1# Remote Access
2
3Use this when you want to connect to a T3 Code server from another device such as a phone, tablet, or separate desktop app.
4
5## Recommended Setup
6
7Use a trusted private network that meshes your devices together, such as a tailnet.
8
9That gives you:
10
11- a stable address to connect to
12- transport security at the network layer
13- less exposure than opening the server to the public internet
14
15## Enabling Network Access
16
17There are three ways to reach your server from another device: expose the desktop app's backend,
18run a headless server from the CLI, or have the desktop app launch T3 Code over SSH.
19
20### Option 1: Desktop App
21
22If you are already running the desktop app and want to make it reachable from other devices:
23
241. Open **Settings** → **Connections**.
252. Under **This environment**, toggle **Network access** on. This will restart the app and run the backend on all network interfaces.
263. The settings panel will show the default reachable endpoint, with a `+N` control when more endpoints are available. Expand it to inspect alternatives such as loopback, LAN, private-network, or HTTPS endpoints.
274. Use **Create Link** to generate a pairing link you can share with another device.
28
29The default endpoint controls the QR code and primary copy action for pairing links. You can change it from the expanded endpoint list. The preference is stored by endpoint type, so choosing the local LAN endpoint survives normal IP address changes when you move between networks.
30
31When no user default is saved, the app uses the built-in LAN endpoint for pairing links when
32available. You can set another endpoint as the default from the expanded endpoint list.
33
34- HTTPS/WSS-compatible endpoints work from `https://app.t3.codes`, but are not made the default
35 automatically.
36- Non-loopback HTTP endpoints are useful for direct LAN pairing.
37- Loopback-only endpoints are not useful for another device unless that device is the same machine.
38
39If the copied link points directly at `http://192.168.x.y:3773`, open it from a client that can reach that LAN address. If it points at `https://app.t3.codes/pair?...`, the hosted web app will save the environment and connect directly to the backend URL in the link.
40
41### Tailscale Endpoints
42
43When the desktop app can detect Tailscale, it adds Tailnet endpoints to the reachable endpoint list.
44
45Depending on your Tailscale setup, this may include:
46
47- the machine's `100.x.y.z` Tailnet IP
48- a MagicDNS name
49- an HTTPS MagicDNS endpoint when Tailscale Serve is configured for this backend
50
51The Tailscale HTTPS endpoint uses the clean MagicDNS URL, such as
52`https://machine.tailnet.ts.net/`, and is off until you opt in. Turn on **Enable Tailscale HTTPS**
53on the **Tailscale HTTPS** row in **Settings** → **Connections**. The desktop app restarts the
54backend with the same server-side behavior as `t3 serve --tailscale-serve`, then the server asks
55Tailscale Serve to proxy HTTPS traffic to the local backend. Turn the same switch off to stop it.
56
57The Tailscale support is an endpoint provider add-on. The core remote model still works without Tailscale: LAN HTTP endpoints, custom HTTPS endpoints, future tunnels, and SSH-launched environments all use the same saved environment and pairing flow.
58
59For `https://app.t3.codes`, prefer an HTTPS Tailnet or other HTTPS endpoint. A plain `http://100.x.y.z:3773` endpoint can still work from a desktop client or another browser page served over HTTP, but it will not work from the hosted HTTPS app because of browser mixed-content rules.
60
61### Option 2: Headless Server (CLI)
62
63Use this when you want to run the server without a GUI, for example on a remote machine over SSH.
64
65Run the server with `t3 serve`.
66
67```bash
68npx t3 serve --host "$(tailscale ip -4)"
69```
70
71`t3 serve` starts the server without opening a browser and prints:
72
73- a connection string
74- a pairing token
75- a pairing URL
76- a QR code for the pairing URL
77
78From there, connect from another device in either of these ways:
79
80- scan the QR code on your phone
81- in the desktop app, enter the full pairing URL
82- in the desktop app, enter the host and token separately
83- in the hosted web app, open a hosted pairing URL when the backend is reachable over HTTPS
84
85Use `t3 serve --help` for the full flag reference. It supports the same general startup options as the normal server command, including an optional `cwd` argument.
86
87For hosted web pairing over Tailscale HTTPS, opt in to Tailscale Serve:
88
89```bash
90npx t3 serve --tailscale-serve
91```
92
93By default this configures Tailscale Serve on HTTPS port 443 and advertises
94`https://machine.tailnet.ts.net/`. Advanced users can choose a different HTTPS port:
95
96```bash
97npx t3 serve --tailscale-serve --tailscale-serve-port 8443
98```
99
100Once paired, add projects normally: open the Command Palette and choose **Add Project**, then pick
101the environment the project lives on. Every saved environment is offered, not only the local one.
102
103### Option 3: Desktop-Managed SSH Launch
104
105Use this when you want the desktop app to start or reuse T3 Code on another machine over SSH.
106
1071. Open **Settings** → **Connections**.
1082. Under **Remote Environments**, choose **Add environment**.
1093. Select the SSH launch flow.
1104. Enter the SSH target, such as `user@example.com`.
1115. Confirm the launch. The desktop app probes the host, starts or reuses a remote T3 server, opens a local port forward, and saves the environment.
112
113After setup, the renderer connects to a local forwarded HTTP/WebSocket endpoint. The remote host still owns the actual T3 server, projects, files, git state, terminals, and provider sessions.
114
115SSH launch is a desktop feature because it needs local process and SSH access. Once the environment is paired and saved, it uses the same environment list and connection model as direct LAN, Tailscale, HTTPS, or future tunnel-backed environments.
116
117#### SSH Launch Troubleshooting
118
119The desktop SSH launcher connects with a non-interactive `sh` session, writes a small launcher script under `~/.t3/ssh-launch/<host-key>/`, starts or reuses a remote T3 server, and forwards the remote loopback port back to your desktop.
120
121The remote host must have a compatible Node.js runtime. T3 Code uses the server package's `engines.node` requirement:
122
123```text
124^22.16 || ^23.11 || >=24.10
125```
126
127During SSH launch, T3 Code first checks whether `node` is on `PATH`. If it is missing, the launcher
128looks in the usual install directories and tries to activate a version manager if it finds one
129(Volta, asdf, mise, fnm, nodenv, nvm). That covers most setups, but a version manager that only
130initializes from an interactive shell profile will not be picked up.
131
132If launch fails with `node: command not found`, a port-scan failure, or a message that the remote Node version does not satisfy the required range, SSH into the host and check the same non-interactive shell path T3 Code uses:
133
134```bash
135ssh user@example.com 'sh -lc "command -v node && node --version"'
136```
137
138If that does not print a compatible Node version, configure your version manager for non-interactive shells or install a compatible Node binary in one of the searched locations. For example, with nvm you may need a default alias:
139
140```bash
141nvm alias default 24
142```
143
144With mise, asdf, fnm, or nodenv, make sure the tool's shim directory is installed and resolves to a Node version satisfying the range above without an interactive shell.
145
146If reconnecting after an app update fails, retry the SSH launch once. The launcher now compares its generated runner script, stops stale launcher-managed remote servers, clears the SSH launch PID/port state, and starts a fresh remote server. You should not normally need to delete `~/.t3/ssh-launch` or kill `t3` processes manually.
147
148## Updating a Remote Server
149
150When the T3 Code web or desktop app and a remote server use different versions, a warning appears in
151the conversation and in **Settings** → **Connections**. Follow the action shown there: T3 Code may
152be able to update and reconnect the server for you, or it may ask you to update the desktop app or
153run a copied command on the server machine.
154
155Finish active work before updating because the server restarts briefly. For step-by-step guidance,
156see [Keeping T3 Code in Sync](./updating.md).
157
158On a Linux host, you can keep the server running after logout and manage it independently of the
159connection method. See [Running T3 Code in the Background](./background-service.md).
160
161## How Pairing Works
162
163The remote device does not need a long-lived secret up front.
164
165Instead:
166
1671. `t3 serve` issues a one-time owner pairing token.
1682. The remote device exchanges that token with the server.
1693. The server creates an authenticated session for that device.
170
171After pairing, future access is session-based. You do not need to keep reusing the original token unless you are pairing a new device.
172
173## Hosted Web App Pairing
174
175The hosted web app at `https://app.t3.codes` can save a remote backend in browser local storage from a URL like:
176
177```text
178https://app.t3.codes/pair?host=https://backend.example.com:3773#token=PAIRCODE
179```
180
181Use hosted pairing when the backend is reachable from the browser over HTTPS/WSS. This includes a backend behind a trusted HTTPS tunnel or another HTTPS endpoint you operate.
182
183Do not use hosted pairing for plain HTTP LAN URLs such as `http://192.168.x.y:3773`. Browsers block an HTTPS page from connecting to an insecure HTTP or WS backend. For those endpoints, use the direct pairing URL shown by the desktop app or CLI from a client that can open that HTTP URL directly.
184
185Hosted pairing does not proxy traffic through T3 Code. The browser still connects directly to the backend URL in the pairing link.
186
187## Managing Access Later
188
189Use `t3 auth` to manage access after the initial pairing flow.
190
191Typical uses:
192
193- issue additional pairing credentials
194- inspect active sessions
195- revoke old pairing links or sessions
196
197Use `t3 auth --help` and the nested subcommand help pages for the full reference.
198
199## Security Notes
200
201- Treat pairing URLs and pairing tokens like passwords.
202- Prefer binding `--host` to a trusted private address, such as a Tailnet IP, instead of exposing the server broadly.
203- Anyone with a valid pairing credential can create a session until that credential expires or is revoked.
204- Hosted pairing links keep the credential in the URL hash so it is not sent to the hosted app server, but it can still be exposed through browser history, screenshots, logs, or copy/paste.
205- Use `t3 auth` to revoke credentials or sessions you no longer trust.