The non-relativistic quantum dynamics of nuclei and electrons is solved within the framework of quantum hydrodynamics using the adiabatic representation of the electronic states. An on-the-fly trajectory-based nonadiabatic molecular dynamics algorithm is derived, which is also able to capture nuclear quantum effects that are missing in the traditional trajectory surface hopping approach based on the independent trajectory approximation. The use of correlated trajectories produces quantum dynamics, which is in principle exact and computationally very efficient. The method is first tested on a series of model potentials and then applied to study the molecular collision of H with H2 using on-the-fly TDDFT potential energy surfaces and nonadiabatic coupling vectors.