Context. The study of prestellar cores is critical as they set the initial conditions in star formation and determine the final mass of the stellar object. To date, several hypotheses have described their gravitational collapse. Deriving the dynamical model that fits both the observed dust and the gas emission from such cores is therefore of great importance. Aims. We perform detailed line analysis and modeling of H2D+ 110–111 and N2H+ 4–3 emission at 372 GHz, using 2′ × 2′ maps (James Clerk Maxwell Telescope; JCMT). Our goal is to test the most prominent dynamical models by comparing the modeled gas kinematics and spatial distribution (H2D+ and N2H+) with observations toward four prestellar (L1544, L183, L694-2, L1517B) and one protoste...