Hydrogels have been developed to respond to a wide variety of stimuli, but their use in macroscopic systems has been hindered by slow response times (diffusion being the rate-limiting factor governing the swelling process). However, there are many natural examples of chemically driven actuation that rely on short diffusion paths to produce a rapid response. It is therefore expected that scaling down hydrogel objects to the micrometre scale should greatly improve response times. At these scales, stimuli-responsive hydrogels could enhance the capabilities of microfluidic systems by allowing self-regulated flow control. Here we report the fabrication of active hydrogel components inside microchannels via direct photopatterning of a liquid phase. Our approach greatly simplifies system construction and assembly as the functional components are fabricated in situ, and the stimuli-responsive hydrogel components perform both sensing and actuation functions. We demonstrate significantly improved response times (less than 10 seconds) in hydrogel valves capable of autonomous control of local flow.