An optofluidic maskless photopolymerization process was developed for in situ negatively charged nanoporous hydrogel ͓poly-AMPS ͑2-acrylamido-2-methyl-1-propanesulfonic acid͔͒ fabrication. The optofluidic maskless lithography system, which combines a high power UV source and digital mirror device, enables fast polymerization of arbitrary shaped hydrogels in a microfluidic device. The poly-AMPS hydrogel structures were positioned near the intersections of two microchannels, and were used as a cation-selective filter for biological sample preconcentration. Preconcentration dynamics as well as the fabricated polymer shape were analyzed in three-dimensions using fluorescein sample and a confocal microscope. Finally, single-stranded DNA preconcentration was demonstrated for polymerase chain reaction-free signal enhancement.