> For the complete documentation index, see [llms.txt](https://bubblegum-reality.gitbook.io/bubblegum-reality-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bubblegum-reality.gitbook.io/bubblegum-reality-docs/operations/deployment.md).

# Deployment

## Target

Server functions and SSR run in a serverless edge Worker (Cloudflare `workerd`) with `nodejs_compat`. There is no Node host to fall back to and **no runtime module resolution** — everything is bundled at build time.

## Publishing

Deploy to any edge-capable host that supports TanStack Start / Vite SSR. Build artifacts are self-contained; configure the secrets in [Environment](/bubblegum-reality-docs/getting-started/environment.md) before starting the server.

Stable URLs depend on your hosting provider.

## Environment

Configure before publishing — see [Environment](/bubblegum-reality-docs/getting-started/environment.md):

| Variable                        | Scope                                        |
| ------------------------------- | -------------------------------------------- |
| `ZEROX_API_KEY`                 | server secret                                |
| `ROBINHOOD_RPC_URL`             | server secret                                |
| `RESTRICTED_REGIONS`            | server, optional; overrides the default list |
| `VITE_WALLETCONNECT_PROJECT_ID` | client, publishable                          |

Secrets are injected at call time. Read them inside `.handler()`; at module scope they are `undefined`.

## Runtime constraints

**Unavailable** — will fail at runtime: `child_process` (stubbed; throws `[unenv] ... is not implemented yet!`), `sharp`, `canvas`, `puppeteer`, `fs.watch`, `os.cpus()`, and any package needing native addons or a real OS filesystem.

**Available**: `fs` (virtual), `path`, `crypto`, `Buffer`, `stream`, `url`, `events`, `timers`, `net`, `http`, `https`, `zlib`.

Prefer pure JS, Web-standard APIs, fetch-based clients, and edge-targeted WASM builds. Signs a package will not work: `node-gyp` / `prebuild-install` in its README, `.node` files or `binding.gyp` at the package root, spawning subprocesses.

Never set `ssr.external` or `resolve.external` for the Worker SSR environment in `vite.config.ts` — it assumes runtime resolution exists and hard-fails the build.

## Errors that mean incompatibility, not a bug

| Symptom                             | Cause                                              |
| ----------------------------------- | -------------------------------------------------- |
| `[unenv] X is not implemented yet!` | Stubbed method — pick another module               |
| `Cannot find module 'X'` at runtime | Native addon or runtime resolution                 |
| `__dirname is not defined`          | Node CommonJS globals in an ESM Worker bundle      |
| Works in dev, crashes in prod       | Dev runs on Node; always verify a production build |

## Pre-deploy checklist

```bash
bun run test && bun run lint && bun run build
grep -rl "ZEROX_API_KEY\|ROBINHOOD_RPC_URL" dist/client || echo "clean"
```

Then confirm: favicon and head metadata resolve, hero film falls back to the poster on error, the status strip degrades honestly with secrets absent, and the wrong-network banner triggers on a non-4663 chain.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://bubblegum-reality.gitbook.io/bubblegum-reality-docs/operations/deployment.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
