  We report a theoretical study of the coherence dynamics of spin qubits in
two-dimensional materials (2DMs) and van-der-Waals heterostructures, as a
function of the host thickness and the composition of the surrounding
environment. We focus on MoS$_2$ and WS$_2$, two promising systems for quantum
technology applications, and we consider the decoherence arising from the
interaction of the spin qubit with nuclear spins. We show that the Hahn-echo
coherence time is determined by a complex interplay between the source of
decoherence in the qubit host and in the environment, which in turn determines
whether the noise evolution is in a classical or quantum mechanical regime. We
suggest that the composition and thickness of van-der-Waals heterostructures
encapsulating a qubit host can be engineered to maximize coherence times.
Finally, we discuss how quantum sensors may be able to probe the dynamics of
the nuclear bath in 2DMs.
