Yes, you can. In situations of this sort, 'have to' = 'need to' . I don't find one preferable over the other, however; they are both common and essentially synonymous in intent.
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.