Skip to Content

env

The object holding your app’s secrets and settings, imported from manh/env. Server code (.ts) only.

Usage

app/payments/repository.ts
import { env } from "manh/env"; import { fail } from "manh/errors"; export async function createPayment(orderId: number, amount: number) { if (!env.PAY_API_KEY) fail(503, "Payment gateway not configured", "PAY_NOT_CONFIGURED"); const res = await fetch("https://pay.example.vn/v1/payments", { method: "POST", headers: { authorization: `Bearer ${env.PAY_API_KEY}`, "content-type": "application/json" }, body: JSON.stringify({ orderId, amount, returnUrl: `${env.MANH_APP_URL}/orders/${orderId}` }), }); return res.json(); }

Signature

manh/env
export const env: Record<string, string | undefined>;

Parameters

None. env is an object; read env.NAME.

Returns

Each key is a string, or undefined when not set. There are two groups:

  • Your secrets: set them with the MCP command env_set({ project, name, value }) or in the project’s Secrets page. A new value applies at once, no redeploy. env_list returns names only, never values.
  • Values manh.run sets for every app: JWT_SECRET (the key that signs sign-in tokens, one per app), MANH_APP_URL (the app’s address, your custom domain once active), MANH_APP_NAME (the project name).

Examples

Write secret names in UPPER_SNAKE. Don’t use names starting with FT_, MANH_ or OPENAI_, and don’t use JWT_SECRET: those belong to manh.run.

app/lib/token.ts
import { sign } from "hono/jwt"; import { env } from "manh/env"; export const issue = (userId: number) => sign({ sub: userId }, env.JWT_SECRET!, "HS256");
  • Email, AI and file storage need no key: use manh/email, manh/openai, manh/blob. Reading env.OPENAI_API_KEY or another reserved name is a check error, code.no-reserved-env, and the value is undefined at runtime.
  • Don’t use process.env or Deno.env. manh/env is the only module for reading settings.
  • .tsx pages can’t import manh/env: secrets never reach the browser.

Next steps

Last updated