We have designed, fabricated, and tested a compact gas-phase reactor for performing in situ soft x-ray scanning transmission x-ray microscopy (STXM) measurements. The reactor mounts directly to the existing sample holder used in the majority of STXM instruments around the world and installs with minimal instrument reconfiguration. The reactor accommodates many gas atmospheres, but was designed specifically to address the needs of measurements under water vapor. An on-board sensor measures the relative humidity and temperature inside the reactor, minimizing uncertainties associated with measuring these quantities outside the instrument. The reactor reduces x-ray absorption from the process gas by over 85% compared to analogous experiments with the entire STXM instrument filled with process gas. Reduced absorption by the process gas allows data collection at full instrumental resolution, minimizes radiation dose to the sample, and results in much more stable imaging conditions. The reactor is in use at the STXM instruments at beamlines 11.0.2 and 5.3.2.2 at the Advanced Light Source.