The stability of hydrogen on nonpolar and semipolar orientations during the metal-organic vapor-phase epitaxy growth is systematically investigated on the basis of density-functional total-energy calculations. The calculated surface energies demonstrate that there are several reconstructions depending on the growth conditions. Using surface phase diagrams which are obtained by comparing the calculated adsorption energy with vapor-phase chemical potentials, we find semipolar GaN(1 1 2bar 2) surface forms N-H and Ga-NH2 bonds beyond ∼1000 K while nonpolar GaN surface without hydrogen is stabilized ranging 1200-1400 K. The stabilization of hydrogen free surfaces in the nonpolar orientation can be interpreted in terms of the electron counting rule, in which surface dangling bonds of Ga and N are empty and filled by electrons, respectively. For InN, on the other hand, the surfaces with hydrogen are stabilized over the wide range of growth conditions regardless of surface orientation. This is because the growth temperatures of InN are much lower than those of GaN. These results thus suggest that the growth kinetics and its orientation dependence could be different between GaN and InN surfaces.