Skip to content
V2 has arrived! A lot has changed, so treat this as a fresh start.

BaseInteractionContext

The BaseInteractionContext is the core context object passed to all interaction handlers and middleware. It extends Hono’s Context and provides access to the environment, variables, and interaction-specific data.

  • TBindings: Custom environment bindings (e.g., Cloudflare Workers environment).
  • TVariables: Custom Hono variables.
  • TPath: The path type for the context (defaults to /).
type BaseInteractionContext<
TBindings extends Bindings = any,
TVariables extends Variables = any,
TPath extends string = "/",
> = Context<BaseHonocordEnv<TBindings, TVariables>, TPath, BlankInput>;

Users typically define their own context type to get full type safety for their environment bindings and custom variables.

import type { BaseHonocordEnv, BaseInteractionContext } from "honocord";
export interface MyEnv {
DISCORD_TOKEN: string;
DATABASE: D1Database;
}
export interface MyVariables {
userId: string;
}
export type MyContext = BaseInteractionContext<MyEnv, MyVariables>;