From Matthew 1 & 2
…an angel of the Lord appeared to him in a dream and said, “Joseph son of David, do not be afraid to take Mary home as your wife, because what is conceived in her is from the Holy Spirit. She will give birth to a son, and you are to give him the name Jesus, because he will save his people from their sins.” …When Joseph woke up, he did what the angel of the Lord had commanded him and took Mary home as his wife.
When they (the Magi) had gone, an angel of the Lord appeared to Joseph in a dream. “Get up,” he said, “take the child and his mother and escape to Egypt. Stay there until I tell you, for Herod is going to search for the child to kill him.” So he got up, took the child and his mother during the night and left for Egypt, where he stayed until the death of Herod.
After Herod died, an angel of the Lord appeared in a dream to Joseph in Egypt and said, “Get up, take the child and his mother and go to the land of Israel, for those who were trying to take the child’s life are dead.” So he got up, took the child and his mother and went to the land of Israel. But when he heard that Archelaus was reigning in Judea in place of his father Herod, he was afraid to go there.
Having been warned in a dream, he withdrew to the district of Galilee, and he went and lived in a town called Nazareth. So was fulfilled what was said through the prophets, that he (the savior) would be called a Nazarene.