> ## Documentation index
> Fetch the complete documentation index at: https://upstash.com/docs/llms.txt
> Search it with GET https://upstash.com/docs/search?q=<query>.
> Use these to discover all available pages before exploring further.

# Host T3 Code in a Remote Sandbox

This guide walks you through running [T3 Code](https://t3.codes) inside an Upstash Box and opening it from any browser or phone. The agent works in the box, the box sleeps when you are away, and it wakes when you open the URL again.

---

## 1. Create a Box

Create a box with the Node.js runtime and default settings. See the [quickstart](/box/overall/quickstart) if you haven't created one before.

---

## 2. Connect via SSH

Connect to the box from your terminal, using your [Box API key](/box/overall/quickstart#1-get-your-api-key) as the password when prompted:

```bash
ssh <box-id>@us-east-1.box.upstash.com
```

The `box-id` is the name of your box (e.g. `right-flamingo-14486`). The next three steps run in this terminal.

---

## 3. Install T3 Code

```bash
sudo npm install -g t3
```

---

## 4. Sign In Your Agent

The agent runs inside the box, so sign in here:

```bash
claude auth login      # or: codex login
```

It prints a link and a code. Open the link in your browser, approve, and you are signed in. The login is saved in the box, so you only do this once.

T3 Code uses Codex to name threads, so either sign in to Codex too or switch the title provider to Claude. See the T3 Code docs for [Claude](https://github.com/pingdotgg/t3code/blob/main/docs/user/providers-claude.md) and [Codex](https://github.com/pingdotgg/t3code/blob/main/docs/user/providers-codex.md) for provider settings.

---

## 5. Start T3 Code

Start the server on all interfaces so the public URL can reach it, with its data under `/workspace`, the box's persistent storage. Then print the pairing link it writes on startup:

```bash
setsid nohup t3 serve --host 0.0.0.0 --port 3773 --base-dir /workspace/home/.t3 > /tmp/t3.log 2>&1 < /dev/null &
sleep 5 && grep "Pairing URL" /tmp/t3.log
```

```
Pairing URL: http://172.18.0.11:3773/pair#token=LTTPGQ8SAX39
```

The shell reports the job as `Done` right away. That is the launcher handing the server off to its own session; the server keeps running.

The pairing link works once and expires after 5 minutes, so create the public URL next and pair right after. To pair another browser later, or if it expired, mint a new one from the SSH terminal:

```bash
t3 pair --base-dir /workspace/home/.t3
```

---

## 6. Create a Public URL

Open the box in the console and create a public URL for port `3773`.

<img src="/img/t3-code-setup/public-url.png" alt="Create a public URL for port 3773" />

Your URL will look like:

```
https://<box-id>-3773.preview.box.upstash.com
```

---

## 7. Pair Your Browser

Take the pairing link from step 5, replace the address with your public URL from step 6, keep the token, and open it in your browser:

```
https://<box-id>-3773.preview.box.upstash.com/pair#token=LTTPGQ8SAX39
```

Your browser stays signed in for 30 days. Anyone with a valid pairing link can sign in the same way, so treat the link as a password.

---

## 8. Start Coding

Add a project and start a thread. Projects you create by name are stored under the server's data directory on persistent storage, so they survive restarts and are captured by snapshots.

<img src="/img/t3-code-setup/thread.png" alt="A thread running in T3 Code on an Upstash Box" />

Close the browser, and the agent keeps working in the box. Open the URL from your phone later and your threads are still there.

---

## 9. Set Init Command for Auto-Restart

When the box has been idle it pauses, and opening the URL wakes it. To bring T3 Code back automatically on every start, open the box in the Upstash Console, go to Settings, then Init Command, and save the start command from step 5:

```bash
setsid nohup t3 serve --host 0.0.0.0 --port 3773 --base-dir /workspace/home/.t3 > /tmp/t3.log 2>&1 < /dev/null &
```

<img src="/img/t3-code-setup/init-command.png" alt="T3 Code init command in the Upstash Console" />

---

## Good to Know

- Everything T3 Code keeps, including projects, threads and your browser pairing, lives under `/workspace/home/.t3` on persistent storage. If you point a project at an existing folder, keep that under `/workspace` too.
- After a reset, install T3 Code again (step 3). A snapshot restore brings your projects and pairing back as they were.
- If a thread says "Claude could not authenticate", the sign-in from step 4 is missing. Sign in and start a new thread.
