On your iPhone, iPad, or iPod touch with iOS 10.3 or later, go to Settings > [your name] > iCloud > Photos, then turn on iCloud Photos.
If in the previous iPhone , if photos box was turned on and photos were saved on the iCloud server , when you sign in with same Apple ID and password the photos will always sync .