Hono foundations
Use context deliberately
Read request data, set response metadata, and pass typed per-request values through Hono context.
9 minute lesson
Authentication middleware stores a typed user id for later handlers without using a process-global variable. That contrast gives us something useful to test instead of a rule to memorize.
Context belongs to one request and is a useful carrier for validated state, bindings, and middleware results. The useful target is not encyclopedic coverage. Make one deliberate choice, observe its consequences, and know which requirement would make you revise it.
The happy path can hide a bad design: you can put request-specific identity or database state in module globals and still get one successful demo. Push past the demo. set narrowly named context variables in middleware and declare their types where the application is created, then test the condition most likely to prove the choice wrong.
The module is moving toward one outcome: Build the smallest portable Hono application and identify exactly which parts depend on its runtime. Save the before-and-after evidence now; it will make the final project review much more honest.
Attach a request id and user object, then prove simultaneous requests do not see each other’s values. Save the evidence, then explain which requirement would force you to choose a different design.
Lesson completed