Wavefront sensors work by detecting the deviations of light waves as they pass through different media. The most common type of wavefront sensor is the Shack-Hartmann sensor, which uses an array of lenslets to focus incoming light onto a detector. By analyzing the position of the focal spots on the detector, the wavefront sensor can calculate the aberrations present in the light wave. This information is crucial for high-resolution imaging and correcting optical distortions.