ZnO is a wide-bandgap (3.37 eV at room temperature) oxide semiconductor that is attractive for its great potential in short-wavelength optoelectronic devices, in which high quality films and heterostructures are essential for high performance. In this study, controlled growth of ZnO-based thin films and heterostructures by molecular beam epitaxy (MBE) is demonstrated on different substrates with emphasis on interface engineering. It is revealed that ultrathin AlN or MgO interfacial layers play a key role in establishing structural and chemical compatibility between ZnO and substrates. Furthermore, a quasi-homo buffer is introduced prior to growth of a wurtzite MgZnO epilayer to suppress the phase segregation of rock-salt MgO, achieving wide-range bandgap tuning from 3.3 to 4.55 eV. Finally, a visible-blind UV detector exploiting a double heterojunction of n-ZnO/insulator-MgO/p-Si and a solar-blind UV detector using MgZnO as an active layer are fabricated by using the growth techniques discussed here.