If your iPhone is running iOS 16 or later, you can recover deleted text messages by looking at the Messages app's "Recently Deleted" section, restoring from an iCloud backup created prior to the deletion, or using an iTunes/Finder backup on a computer. You can try a reliable third-party recovery tool if none of these work and the messages are crucial, but success isn't always assured.