Mail, i18n & observability
Send email over SMTP, translate Niral apps with locale catalogs and monitor requests with built-in observability. Configure helpers without runtime packages.
On this page 3 sections
Mail — own SMTP client
NIRAL_SMTP_URL=smtp://user:[email protected]:587
NIRAL_MAIL_FROM="App <[email protected]>"
await mail({ to, subject: "Reset your password", text, html })
STARTTLS, AUTH, MIME multipart, unicode subjects, header-injection rejection — works with SES, Mailgun, Postmark, Gmail.
i18n
Put catalogs in i18n/ — en.json, ta.json … (nested keys flatten):
<h1>{t("nav.home")}</h1>
<p>{t("greet", { name })}</p>
The locale is negotiated per request — niral_locale cookie (your language switcher sets it) → Accept-Language → default. SSR and client render from the same catalog, so there's no flash. props.locale is on every page.
Observability
Production logs are structured JSON lines with request correlation:
{"t":"…","level":"info","msg":"request","req":"a1b2c3d4","method":"GET","path":"/","status":200,"ms":3.1}
- 4xx and slow requests (
NIRAL_SLOW_MS) escalate to warn, 5xx to error log.info("payment ok", { orderId })— ambient in server blocksGET /@niral/health→ release hash, uptime, pid (for load balancers)NIRAL_LOG=prettyfor humans,=offfor silence