Back up your device. This can be done on a computer or to a cloud program.
Remove any sim/memory cards. If this is easily retractable from your brand of phone, simply pop it out before trading in. If not, proceed to the next step.
Sign out of any accounts. This includes, but is not limited to, cloud program, social accounts, email or anything else requiring a login.
If you’re able to, reset your phone. This function is found in your phone settings.
Apple instructions: https://support.apple.com/en-gb/HT201351
For all other devices, please check with your manufacturer for the appropriate steps to take to clear your device.