The exocomets are detected using spectroscopy when they transit their host stars. The transits of exocomets, like the transits of exoplanets, produce variations in the light received from the star. Changes are observed in the absorption lines of the stellar spectrum: the occultation of the star by the gas cloud coming from the exocomet produces additional absorption features, like those observed in the ionized calcium lines. The cometary gas comes from the evaporation of volatiles and dust ejected from the comet's nucleus heated when it comes close to the star.
Observations of comets, and especially exocomets, provide important elements for understanding planet formation. Indeed, in the standard model of planet formation by accretion, planets are the result of the agglomeration of planetesimals, themselves formed by the coalescence of dust from the protoplanetary disk surrounding the star shortly after its formation. Thus, comets are the residuals of the volatile-rich planetesimals that remained in the planetary system without having been incorporated into the planets. They are considered fossil bodies that have seen the physical and chemical conditions prevailing at the time of planet formation.