Unfortunately non-citizens probably don't have this luxury, but before entering certain countries - including returning to the USA as a citizen from a recent trip abroad, I wipe and do a fresh OS reinstall (simple new password not used anywhere else, zero user data, no email or chat or cloud accounts configured).
Right before the wipe I update my cloud backups of course, and if I've been doing a lot of work I use Carbon Copy Cloner to an SSD encrypted APFS volume and use DHL to ship the SSD to someone I can retrieve it from once home. I also have finally started traveling with a second phone (a cheap Consumer Cellular backup flip phone with only a few family in the address book).
"Password, please" - "sure, no problem: Travel1234 with a capital T."*
Restoring the devices is a bit of a pain, but is faster and easier with the SSD assuming it arrives.
But them's the times we're living in.
* I suppose if it they ever ask and login, CBP will ask "Why doesn't your device have any user data? This is suspicious." I might tell them about the time an Israeli border dude took my computer into a back room for an hour and by the time I got home someone in Israel had stolen and sold one of my better domain names. Or might just shrug and say "Citizen".
I am a little curious in that scenario (thoroughly wiped device, comply with password request) if they still impound the wiped device (after they presumably connect it to whatever digital-strip-search gadget they hide in the back room and it comes back clean).