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 two ways to expose your server for remote connections: from the desktop app or from the CLI.
18
19### Option 1: Desktop App
20
21If you are already running the desktop app and want to make it reachable from other devices:
22
231. Open **Settings** → **Connections**.
242. Under **Manage Local Backend**, toggle **Network access** on. This will restart the app and run the backend on all network interfaces.
253. 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.
264. Use **Create Link** to generate a pairing link you can share with another device.
27
28The 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.
29
30When no user default is saved, the app uses the built-in LAN endpoint for pairing links when
31available. You can set another endpoint as the default from the expanded endpoint list.
32
33- HTTPS/WSS-compatible endpoints work from `https://app.t3.codes`, but are not made the default
34 automatically.
35- Non-loopback HTTP endpoints are useful for direct LAN pairing.
36- Loopback-only endpoints are not useful for another device unless that device is the same machine.
37
38If 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.
39
40### Tailscale Endpoints
41
42When the desktop app can detect Tailscale, it adds Tailnet endpoints to the reachable endpoint list.
43
44Depending on your Tailscale setup, this may include:
45
46- the machine's `100.x.y.z` Tailnet IP
47- a MagicDNS name
48- an HTTPS MagicDNS endpoint when Tailscale Serve is configured for this backend
49
50The Tailscale HTTPS endpoint uses the clean MagicDNS URL, such as
51`https://machine.tailnet.ts.net/`, and is disabled until the app verifies that the URL reaches this
52backend. Use **Setup** on the Tailscale HTTPS row to opt in. The desktop app restarts the backend
53with the same server-side behavior as `t3 serve --tailscale-serve`, then the server asks Tailscale
54Serve to proxy HTTPS traffic to the local backend.
55
56The 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.
57
58For `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.
59
60### Option 2: Headless Server (CLI)
61
62Use this when you want to run the server without a GUI, for example on a remote machine over SSH.
63
64Run the server with `t3 serve`.
65
66```bash
67npx t3 serve --host "$(tailscale ip -4)"
68```
69
70`t3 serve` starts the server without opening a browser and prints:
71
72- a connection string
73- a pairing token
74- a pairing URL
75- a QR code for the pairing URL
76
77From there, connect from another device in either of these ways:
78
79- scan the QR code on your phone
80- in the desktop app, enter the full pairing URL
81- in the desktop app, enter the host and token separately
82- in the hosted web app, open a hosted pairing URL when the backend is reachable over HTTPS
83
84Use `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.
85
86For hosted web pairing over Tailscale HTTPS, opt in to Tailscale Serve:
87
88```bash
89npx t3 serve --tailscale-serve
90```
91
92By default this configures Tailscale Serve on HTTPS port 443 and advertises
93`https://machine.tailnet.ts.net/`. Advanced users can choose a different HTTPS port:
94
95```bash
96npx t3 serve --tailscale-serve --tailscale-serve-port 8443
97```
98
99> Note
100> The GUIs do not currently support adding projects on remote environments.
101> For now, use `t3 project ...` on the server machine instead.
102> Full GUI support for remote project management is coming soon.
103
104### Option 3: Desktop-Managed SSH Launch
105
106Use this when you want the desktop app to start or reuse T3 Code on another machine over SSH.
107
1081. Open **Settings** → **Connections**.
1092. Under **Remote Environments**, choose **Add environment**.
1103. Select the SSH launch flow.
1114. Enter the SSH target, such as `user@example.com`.
1125. 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.
113
114After 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.
115
116SSH 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.
117
118#### SSH Launch Troubleshooting
119
120The 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.
121
122The remote host must have a compatible Node.js runtime. T3 Code uses the server package's `engines.node` requirement:
123
124```text
125^22.16 || ^23.11 || >=24.10
126```
127
128During SSH launch, T3 Code first checks whether `node` is already available on `PATH`. If it is missing, the launcher tries common non-interactive shell locations and version-manager shims/activation hooks:
129
130- `~/.local/bin`, `~/bin`, `/opt/homebrew/bin`, `/usr/local/bin`, `/usr/bin`, `/bin`
131- Volta via `~/.volta/bin`
132- asdf via `~/.asdf/shims`, `~/.asdf/bin`, or `~/.asdf/asdf.sh`
133- mise via `~/.local/share/mise/shims`, `~/.mise/shims`, or `mise activate sh`
134- fnm via `fnm env --use-on-cd --shell sh` or `fnm env --shell sh`
135- nodenv via `~/.nodenv/bin`, `~/.nodenv/shims`, or `nodenv init -`
136- nvm via `$NVM_DIR/nvm.sh`, then `nvm use default`, `nvm use node`, or `nvm use --lts`
137- installed nvm versions under `$NVM_DIR/versions/node/*/bin`
138
139If 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:
140
141```bash
142ssh user@example.com 'sh -lc "command -v node && node --version"'
143```
144
145If 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:
146
147```bash
148nvm alias default 24
149```
150
151With mise/asdf/fnm/nodenv, make sure the tool's shim directory is installed and points at a Node version satisfying the range above.
152
153If 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.
154
155## Updating a Remote Server
156
157When the T3 Code web or desktop app and a remote server use different versions, a warning appears in
158the conversation and in **Settings** → **Connections**. Follow the action shown there: T3 Code may
159be able to update and reconnect the server for you, or it may ask you to update the desktop app or
160run a copied command on the server machine.
161
162Finish active work before updating because the server restarts briefly. For step-by-step guidance,
163see [Keeping T3 Code in Sync](./server-updates.md).
164
165On a Linux host, you can keep the server running after logout and manage it independently of the
166connection method. See [Running T3 Code in the Background](./background-service.md).
167
168## How Pairing Works
169
170The remote device does not need a long-lived secret up front.
171
172Instead:
173
1741. `t3 serve` issues a one-time owner pairing token.
1752. The remote device exchanges that token with the server.
1763. The server creates an authenticated session for that device.
177
178After pairing, future access is session-based. You do not need to keep reusing the original token unless you are pairing a new device.
179
180## Hosted Web App Pairing
181
182The hosted web app at `https://app.t3.codes` can save a remote backend in browser local storage from a URL like:
183
184```text
185https://app.t3.codes/pair?host=https://backend.example.com:3773#token=PAIRCODE
186```
187
188Use 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.
189
190Do 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.
191
192Hosted pairing does not proxy traffic through T3 Code. The browser still connects directly to the backend URL in the pairing link.
193
194## Managing Access Later
195
196Use `t3 auth` to manage access after the initial pairing flow.
197
198Typical uses:
199
200- issue additional pairing credentials
201- inspect active sessions
202- revoke old pairing links or sessions
203
204Use `t3 auth --help` and the nested subcommand help pages for the full reference.
205
206## Security Notes
207
208- Treat pairing URLs and pairing tokens like passwords.
209- Prefer binding `--host` to a trusted private address, such as a Tailnet IP, instead of exposing the server broadly.
210- Anyone with a valid pairing credential can create a session until that credential expires or is revoked.
211- 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.
212- Use `t3 auth` to revoke credentials or sessions you no longer trust.