The first electromagnetic signal observed in different types of cosmic explosions is released upon emergence of a shock created in the explosion from the opaque envelope enshrouding the central source. Notable examples are the early emission from various types of supernovae and low luminosity GRBs, the prompt photospheric emission in long GRBs, and the gamma-ray emission that accompanied the gravitational wave signal in neutron star mergers. In all of these examples, the shock driven by the explosion is mediated by the radiation trapped inside it, and its velocity and structure, that depend on environmental conditions, dictate the characteristics of the observed electromagnetic emission at early times, and potentially also their neutrino emission. Much efforts have been devoted in recent years to develop a detailed theory of radiation mediated shocks in an attempt to predict the properties of the early emission in the aforementioned systems. These efforts are timely in view of the anticipated detection rate of shock breakout candidates by upcoming transient factories, and the potential detection of a gamma-ray flash from shock breakout in neutron star mergers like GW170817. This review aims at providing a comprehensive overview of the theory and applications of radiation mediated shocks, starting from basic principles. The classification of shock solutions, which are governed by the conditions prevailing in each class of objects, and the methods used to solve the shock equations in different regimes will be described, with particular emphasis on the observational diagnostics. The applications to supernovae, low-luminosity GRBs, long GRBs, neutron star mergers, and neutrino emission will be highlighted.