It is better to store BTC in an online wallet, such as COINBASE .
Both have risks. Online wallets can get hacked. Though, coinbase is probably among the most secure places.
If you know how to keep your coins secure, then they won't get hacked or stolen. You can keep your cryptocurrency in any online wallet (but make sure that they allow you to access the private keys). Enable email authentication and 2FA (preferably with Google Authenticator) and your coins will be safe from any hacker. Only in very rare instances (such as an attack using SIM swap, or theft of your mobile phone), you need to worry. But always remember to keep multiple backups of your wallet. Losing access to coins is manytimes more common than coins getting stolen.