Country or region and language

    Choose your country or region and your language.

    Suggested for you

      All countries and regions

        Choose your character

        It shows in the top bar and on your profile. Change it any time.

        Sign in or join
        Opening JavaScript and TypeScript
        Your turn

        Hono middleware

        The onion order

        Middleware is an async (c, next) => { ... } function registered with app.use. Code before await next() runs on the way in and code after it runs on the way out, so two middleware and a handler log a-in, b-in, the handler, b-out, a-out. Middleware registered on * also wraps requests that match no route, which is why a header set after next() can appear on a 404.

        Guards and scoped middleware

        Returning a response without calling next() ends the request there, and the handler never runs. The lesson’s sign-in check works this way: a missing or unknown user header gets a 401 and leaves nothing in the trace. A path pattern such as app.use('/admin/*', ...) keeps the middleware off public routes. The Hono middleware guide lists the built-in middleware; these exercises write their own, so each step is visible.

        Your Work Gym account

        Save your progress and pick up on another device. Your browser's progress comes with you.

        Your account can start a 5-day free trial: every course, unit, project and exam. Card needed; cancel any time and pay nothing.

        New accounts get 6 hours of full access: every course, unit, project and exam. The clock starts when you go past the free lessons.

        Plan your practice from a job ad or syllabus

        Have a referral code?

        or

        You can keep practicing without an account.

        Change your plan

        Checking the price

        Help and feedback

        Ask a question, tell us what is not working, or share an idea. We reply by email.

        What is it about?

        We use it only to reply to you.