Why did most people in the Sahara tend to live along the Nile river or the Mediterranean coast?

Most people in the Sahara tended to live along the Nile river or the Mediterranean coast because these areas provided access to water, which is essential for survival in the desert region. The Nile river, in particular, was a major source of water for agriculture, transportation, and domestic use. Additionally, the Mediterranean coast offered a milder climate and more favorable conditions for living compared to the harsh desert environment further inland. As a result, settlements and civilizations developed along these water sources, allowing people to thrive in an otherwise inhospitable region.