By default, all text messages get stored on your iPhone's local storage. However, if you want them stored in the cloud, you can turn on iCloud for Messages. This will make the messages accessible on any device provided you log in to your iCloud account.