Look at these two sentences expressing the idea of "need":
J'ai besoin d'aller faire les courses avant le dîner.I need to go shopping before dinner.
Je dois aller faire les courses avant le dîner.I need to go shopping before dinner.
Devoir + [infinitif] primarily means must [do] / have to [do], but in some cases it can be used as need to [do].
See Conjugate devoir in the present tense in French (Le Présent)
Avoir besoin de + [infinitif] always means need to [do], as it literally means "to have need of".
See Avoir besoin de = To need (French Expressions with avoir)
As for expressing to need [something], it will always be avoir besoin de [quelque chose] :
Elle a besoin d'aide.She needs help.
Tu as besoin d'argent.You need money.
Devoir [quelque chose] has a completely different meaning = to owe [something].
It can never mean to need [something].
Tu dois de l'argent.You owe money.
Patrick me doit une faveur.Patrick owes me a favour.
Special cases :
"needing to go to the toilet"
As stated above, you can use either avoir besoin de or devoir in that case, but you could also use avoir envie de (= to feel like) in this specific case : though it can sound a bit "whimsical", it's perfectly colloquial here!
Mon fils doit aller aux toilettes.My son needs to go to the toilet.
Mon fils a besoin d'aller aux toilettes.My son needs to go to the toilet.
Mon fils a envie d'aller aux toilettes.My son needs to go to the toilet.
"needing to throw up"
Another weird case is how to say you feel nauseous, need to throw up. In French, the most colloquial expression there is to use once again avoir envie de (= to feel like), though no one really ever "feels like" vomiting!
Arrête la voiture ! J'ai envie de vomir !Stop the car! I feel nauseous!
See also Avoir envie de = To feel like, want to (French Expressions with avoir)
Want to make sure your French sounds confident?
We’ll map your knowledge and give you free lessons to focus on your
gaps and mistakes. Start your Braimap today »