Can border officials search your phone?
In many countries yes, and frequently with fewer legal protections at a border than elsewhere — which surprises travellers and is one of the areas where practice varies most sharply between destinations.
Why borders are different. Many legal systems treat a border as a zone where the usual requirements for suspicion or a warrant are reduced or absent, on the basis that the state controls who and what enters. The result is that a device which could not be examined inside the country can sometimes be examined at the frontier.
What officials can typically do, depending on the country: ask you to unlock the device; inspect its contents manually; in some jurisdictions connect it to equipment for a forensic extraction; and detain the device for a period.
What powers exist to compel you. Some countries can require you to provide a passcode, with refusal itself an offence. Others cannot compel it but may refuse entry to a visitor, detain the device, or treat refusal as grounds for further scrutiny. Citizens and visitors are frequently in different positions — a citizen cannot usually be refused entry to their own country, while a visitor can.
Biometrics versus passcodes. In several jurisdictions, compelling a fingerprint or face unlock has been treated differently in law from compelling a passcode, which is why security guidance frequently suggests disabling biometric unlock before crossing a border so that only a passcode will open the device.
Practical measures for people with genuinely sensitive material — journalists, lawyers, doctors, those handling confidential business information:
Travel with minimal data. A clean device, or one from which sensitive material has been removed, is the only reliable protection.
Store data remotely and remove local copies and cached files.
Log out of accounts rather than relying on them being unexamined.
Power the device off before arrival, since a fully powered-down device is in a more protected cryptographic state.
Know the specific rules for your destination and your status.
Professional obligations may apply — legal privilege and medical confidentiality do not disappear at a border, and relevant professional bodies publish guidance.
General information, not legal advice.