I keep mine in my password manager, which is sync'd across all of my devices. That way, if I lose access to my 2FA device, I can still get into my accounts, even if I'm traveling.
If an attacker is able to compromise my password manager, then quite frankly, I have much bigger issues to worry about than my 2FA codes. But there are ways to make that harder, too. For example, some password managers also support 2FA (mine supports Yubikey).