U.S. border guards can search your phone: here are some details on how

CBC:

“If I go to Canada and visit some of my wife’s relatives, and I come back … they [can] say, ‘We want your laptop and your phone and your pass code.’ And I say, ‘Well, do you have any reason?’ They say, ‘We don’t need one.’ Is that correct? They can do that?”

“Welcome to America,” Vermont Sen. Patrick Leahy added sarcastically.

Agents can demand a password to open your phone, without probable cause, DHS Secretary Kirstjen Nielsen confirmed during the hearing.

This is a concern not just for non-US citizens but also for US citizens arriving back into the country. Know your rights and know what to do and what not to do.