Types
This page lists the shared TypeScript types used in handlers, pages and config.
On this pageType a handler's context and environment · Type head descriptors and route maps · Find where each type comes from
CloudContext
A Hono Context typed with CloudEnv. It is the type of c in every route handler and middleware.
import type { CloudContext } from 'void';CloudEnv
The Hono environment type for SDK Workers. It extends Hono's Env with Cloudflare bindings and context variables.
interface CloudEnv extends Env {
Bindings: {
DB: D1Database;
KV: KVNamespace;
STORAGE: R2Bucket;
AI: Ai;
SANDBOX: DurableObjectNamespace<import('void/sandbox').VoidPlatformSandbox>;
[key: string]: unknown;
};
Variables: CloudContextVariables;
}CloudContextVariables
The type of context variables for c.set() and c.get(). Augment it to add typed variables that every middleware and handler can read:
interface CloudContextVariables {
user: AuthUser | null;
session: AuthSession | null;
[key: string]: unknown;
}Augmentation example:
declare module 'void' {
interface CloudContextVariables {
requestId: string;
}
}
// c.get("requestId") → stringSee Type Safety for details.
TypedHandler<V, R>
The return type of defineHandler. V holds the validator types and R the handler's return type.
interface TypedHandler<V extends ValidatorSlots = {}, R = unknown> {
(c: CloudContext): Promise<Response> | Response | unknown;
readonly __validators: V; // type-level only
readonly __output: R; // type-level only
}HeadDescriptor
The shape of the page head metadata that defineHead returns. All fields are optional.
interface HeadDescriptor {
title?: string;
meta?: Array<{ name?: string; property?: string; content?: string; charset?: string }>;
link?: Array<{ rel: string; href: string; [key: string]: string | undefined }>;
script?: Array<{ src?: string; innerHTML?: string; [key: string]: string | undefined }>;
htmlAttrs?: Record<string, string>;
bodyAttrs?: Record<string, string>;
}RouteMap
Generated route types for the typed fetch client. They hold each route's methods, inputs and outputs.
import type { RouteMap } from 'void/routes';