In Astro framework, protected routes use middleware to check if a user is logged in before allowing access. When a user requests a page, the middleware runs first. It checks if the user is authenticated by looking at context.locals.user. If the user is not authenticated, middleware returns a redirect response to the login page, stopping the route handler from running. If the user is authenticated, middleware does not return a Response, allowing the framework to continue to the route handler, allowing the page to load. This process ensures only logged-in users can access protected pages. The execution table shows two cases: one where the user is logged in and allowed access, and one where the user is redirected to login. The variable tracker shows how context.locals.user and middleware result change during execution. Key moments include understanding why the route handler does not run when redirected and what happens when no Response is returned. The visual quiz tests understanding of these steps and middleware behavior.