HSAs act much like any other savings account and named beneficiaries can inherit the assets. If an account holder dies, a named spouse beneficiary can assume ownership of the account and use it for qualified medical expenses as if it was their own HSA.
If the beneficiary is not a spouse, the account is no longer treated as an HSA. The funds are passed to the designated beneficiary(ies) or becomes part of the account holder's estate and is subject to applicable taxes.