Skip to main content
Develop and test locally with your normal framework dev server (pnpm dev), Vitest, or Node scripts directly against your real hosted ohmyho.st Dev (or Prod) resources — without installing or maintaining local PostgreSQL, R2, or Resend emulators. Your server code calls resolveOhMyHostEnv(workerEnv) once:
  • In Cloudflare Workers (hosted Dev / Prod): returns workerEnv untouched with zero network overhead.
  • Locally (pnpm dev, Vitest, scripts): returns the exact same env bindings backed by the Owner-authenticated Cloud Runtime Bridge on https://app.ohmyho.st.
Prefer letting your coding agent set this up? The ohmyhost-build-portable-app Skill includes the matching local development reference so agents wire .env.local, resolveOhMyHostEnv, and ohmyhost dev automatically.

1. Create an Owner API token and configure .env.local

Local cloud development requires an Owner API token with projects:write (or the narrower Owner-only runtime:use permission) and your project ULID.
  1. Find your organization ULID and project ULID:
  1. Create an Owner API token in the portal at app.ohmyho.st/tokens (default full permission set) or, for least privilege, with the CLI (in a shell where OHMYHOST_TOKEN is unset). Pass --permissions runtime:use (CLI >= 0.1.91) so the local token can only reach the Cloud Runtime Bridge and cannot modify projects or billing:
ohmyhost token create --out writes OHMYHOST_TOKEN=... (the CLI automation variable). Local runtime resolution reads OHMYHOST_API_TOKEN so your interactive CLI login and your application’s local runtime bridge stay cleanly separated.
  1. Add the token and project ULID to .env.local in your application root (and verify .env.local is in .gitignore):

Environment variable reference

Free vs Paid environment targeting

2. Install the runtime package alias

Install @amerged/ohmyhost-runtime under the @ohmyhost/customer-runtime alias (matching ohmyhost init --dry-run --json) and commit the updated lockfile:
Both @ohmyhost/customer-runtime (required for hosted builds) and @amerged/ohmyhost-runtime export resolveOhMyHostEnv and DATABASE_CLIENT_LIMITS for both ESM (import) and Node 22.12+ CommonJS/tsx (require()).

3. Resolve bindings in server code

Call resolveOhMyHostEnv(workerEnv) in server-only code (calling it in a browser throws runtime_env_invalid).

Next.js (App Router / OpenNext)

In Next.js Route Handlers and Server Components, wrap getCloudflareContext({ async: true }) in a try/catch so next dev falls back cleanly to .env.local:

Vite API companion, TanStack Start, Astro SSR, plain Workers, Vitest, and Node scripts

Pass your runtime env when available, or omit it (undefined) in local scripts and tests:

4. Use hosted capabilities locally

Every binding returned by resolveOhMyHostEnv matches the deployed Cloudflare Worker shape:

PostgreSQL (OHMYHOST_DATABASE)

Always pass both text and values (values: [] when there are no parameters; omitting values throws database_query_invalid):
For withConnection and withRls, the runtime exchanges your bearer token over HTTPS for a single-use 30-second HMAC WebSocket ticket so your API token never appears in a WebSocket URL. See Postgres queries, writes and compute and Row-level security for query limits and Kysely usage.

Database client limits (DATABASE_CLIENT_LIMITS) and PostgreSQL column types

Import DATABASE_CLIENT_LIMITS from @ohmyhost/customer-runtime/database to mirror the exact limits enforced both locally and hosted: PostgreSQL column type mapping:
  • int8 / bigint (including COUNT(*)): returned as a decimal string to preserve 64-bit precision (parse with BigInt(...) or Number(...) where safe).
  • numeric / decimal: returned as string.
  • date: returned as YYYY-MM-DD string.
  • timestamptz: returned as a JavaScript Date.
  • bytea: returned as Uint8Array.
  • json / jsonb: returned as parsed JavaScript values.

Private files (OHMYHOST_STORAGE_*)

Private storage requires storage declared in ohmyhost.yaml and deploying the target environment at least once (otherwise the bridge returns 403 gateway_not_enabled).
See Files for upload, read, and delete methods.

Transactional mail (OHMYHOST_MAIL_*)

Requires Paid access, credits, and a verified sender domain on the project. mail.send() returns messageId, an outbound provider identifier (typically a UUID; absent when state is uncertain); ohmyhost mail messages list|get|retry inspects inbound received mail using its inbound ULID, not outbound send identifiers. See Email.

AI gateway (OHMYHOST_AI_*) and Browser PDF (OHMYHOST_BROWSER_*)

  • AI gateway: works immediately from local development on Paid workspaces with credits — even before enabling ai in ohmyhost.yaml and deploying. Local AI defaults to any unless you set OHMYHOST_AI_JURISDICTION=eu or the active deployment is locked to eu. Every non-WebSocket AI response carries x-request-id, and GET /v1/models includes x-ohmyhost-ai-jurisdiction (eu or any).
  • Browser PDF: requires Paid access, credits, and an active deployment whose ohmyhost.yaml enables browser.enabled: true (otherwise the bridge returns 403 gateway_not_enabled).
See AI gateway and Browser PDF for supported routes, limits, and pricing.

Container jobs (OHMYHOST_JOBS_*) and Native Auth (OHMYHOST_AUTH)

  • Container jobs: call ${env.OHMYHOST_JOBS_BASE_URL}/v1/... with Authorization: Bearer ${env.OHMYHOST_JOBS_TOKEN}. See Container jobs.
  • Native Auth: pass env.OHMYHOST_AUTH to createNativeAuthServer(env.OHMYHOST_AUTH) and use auth.getSession(request) or auth.requireUser(request). See Application authentication.

5. Secrets separation (.env.local vs Secret Manager)

  • Platform bindings (OHMYHOST_*): provided locally by resolveOhMyHostEnv and injected automatically by ohmyho.st when deployed. Never add OHMYHOST_* names to the platform Secret Manager.
  • Third-party and application secrets (such as STRIPE_SECRET_KEY, APP_AUTH_SECRET, APP_URL): stay in .env.local during local development and remain write-only in the platform Secret Manager when deployed. ohmyho.st never pulls secret values back down to your laptop; upload them separately for Dev and Prod using ohmyhost secret set or ohmyhost secret form create.

6. Local edge parity, crons, webhooks, and live logs

The CLI (@amerged/ohmyhost-cli >= 0.1.87; --permissions on token create requires >= 0.1.91) provides local parity commands that read your ohmyhost.yaml and .env.local:

Run your Worker locally with egress parity (ohmyhost dev --edge)

Runs your local Worker bundle on 127.0.0.1 with the Cloud Runtime Bridge bindings and enforces runtime.egress.allow from ohmyhost.yaml — blocking unlisted or retired hosts with HTTP 403 (Outbound request blocked) and refusing redirects with HTTP 502, matching hosted Workers.

Trigger scheduled cron handlers locally (ohmyhost dev cron trigger)

Validates every requested cron expression against functions.crons in ohmyhost.yaml before dispatching scheduled(controller, env, ctx).

Replay signed webhooks locally (ohmyhost dev webhook replay)

Builds and signs an authentic Standard Webhooks HMAC payload (webhook-id, webhook-timestamp, webhook-signature) and delivers it strictly to loopback (127.0.0.1, localhost, [::1]) without printing secrets.

Follow live hosted runtime logs (ohmyhost deployment logs --follow)

Polls redacted runtime 5xx and uncaught exception diagnostics (route, status_code, request_id, duration_ms, and safe exception_class — never exception messages, query strings, or secrets) until interrupted.

7. Troubleshooting

CLI · Postgres · Runtime secrets · Troubleshooting.