See the article Access your messages on all your Apple devices - Apple Support
The same Apple ID and password is signed in both devices on the same network .
- In the Messages app on your Mac, choose Messages > Preferences, then click iMessage.
- In the Settings pane, select Enable Messages in iCloud.
- The messages from your other devices that use the same Apple ID appear on your Mac.
- Note: Depending on how many messages you have, it may take a while for all of them to appear. You can send and receive messages during that time.
To make sure you’re seeing the latest messages in iCloud on your Mac, choose Messages > Preferences, click iMessage, then click Sync Now in the Settings pane.
Read Set up Messages on iPhone - Apple Support