I want to buy a hardware wallet for storing bitcoin because it is safe than an online wallet but at the same time, I am thinking that what will happen to my stored bitcoin if my hardware wallet damaged. Can I recover my bitcoin?
I am answering this based on Ledger Nano S:
Considering a scenario where you have configured your hardware wallet and have been using it for some time. And unfortunately, it got burnt or drowned or destroyed or lost.
You will still have your backup phrase which you made while setting up your Ledger Nano S. Your backup phrase is a 24 word list, which you can use to restore your previous account.
So, if you have another Ledger Nano S or any other wallet which support BIP39 deterministic keys, you can simply input these words and restore your wallet.
Another helpful source to restore your Ledger wallet is here
Hope this assures you to buy a hardware wallet.
Assuming the Ledger Nano S implements BIP 39, your hardware wallet probably showed you a 12/24/36 word Mnemonic code. If you wrote these mnemonic code words down, then you can restore your corrupted hardware wallet with just these words. Also, you can use these words to restore any wallet that supports BIP 39. This includes many mobile phone wallets and other hardware wallets. If you did not write these code words down, then you are probably out of luck for recovering your wallet keys.