This article explains how to transfer your text messages and iMessage history from your iPhone to a new iPhone. The instructions refer to Apple's Messages texting app, which comes preinstalled on the iPhone. It does not cover third-party texting apps such as WhatsApp.
How to Transfer Text Messages from Old iPhone to New iPhone
Perhaps the easiest way to transfer text messages from iPhone to iPhone is Messages in iCloud. This iCloud feature was introduced in iOS 11.4.
Once you turn it on, it works just like iCloud syncing does for other data: you upload content to iCloud, and then all other devices signed into the same account download messages from iCloud. It’s pretty simple, and it includes both standard SMS messages and iMessages.
On your current iPhone, tap Settings to open it.