Hello World

Docs

A route is server code that receives a request and returns a response. This demo sends JSON to a Hono route, validates the body, logs the request, and returns a typed response. Start here before adding storage, model calls, or background work. Once you're comfortable here, explore Route Context to see request data, logging, and service clients.

Waiting for request
Reference Code
import { agentuity } from "@agentuity/hono";
import type { Logger } from "@agentuity/hono";
import { Hono } from "hono";
import { z } from "zod";

type Variables = { logger: Logger };

const app = new Hono<{ Variables: Variables }>();
// The middleware adds Agentuity helpers to c.var for each request.
app.use("*", agentuity());

const HelloInput = z.object({
  name: z.string().min(1).default("World"),
});

app.post("/api/hello", async (c) => {
  const input = HelloInput.parse(await c.req.json());
  c.var.logger.info("Processing greeting", { name: input.name });

  return c.json({
    greeting: "Hello, " + input.name + "! Welcome to Agentuity.",
  });
});

export default app;
Ready
Output will appear here...