Forming hydrogels with precise geometries is challenging and mostly done using photopolymerization, which involves toxic chemicals, rinsing steps, solvents, and bulky optical equipment. Here, we introduce a new method for in situ formation of hydrogels with a well-defined geometry in a sealed microfluidic chip by interfacial polymerization. The geometry of the hydrogel is programmed by microfluidic design using capillary pinning structures and bringing into contact solutions containing hydrogel precursors from vicinal channels. The characteristics of the hydrogel (mesh size, molecular weight cut-off) can be readily adjusted. This method is compatible with capillary-driven microfluidics, fast, uses small volumes of reagents and samples, and does not require specific laboratory equipment. Our approach creates opportunities for filtration, hydrogel functionalization, and hydrogel-based assays, as exemplified by a rapid, compact competitive immunoassay that does not require a rinsing step.Hydrogels are excellent materials for microfluidic applications in biomedicine and biosensing owing to their compatibility with proteins and numerous solvents, permeability to small chemicals, transparency, potential for functionalization, and programmable stiffness. [1][2][3][4][5] For example, hydrogels have been employed for fabricating membranes in chips for microdialysis, [6,7] filtration, [8] preconcentration of proteins in electrophoresis, [9] or studying solvophoresis [10] and diffusophoresis. [11] Likewise, hydrogels are frequently applied for the immobilization of biomolecular receptors in microfluidics to enable sensitive detection of proteins, [12,13] nucleic acids, [14] or small-molecule targets. [15] Moreover, due to their tunable response to temperature, pH, light, electric and magnetic fields, hydrogels are increasingly being used as microfluidic actuators, which leads to numerous novel applications. [16][17][18]