In many states a home loan is “non recourse”, which means that in a default the bank gets the house and nothing else. The debt is completely discharged.
You’re eligible for a new mortgage within ~3 years after foreclosure with an FHA mortgage, 7 for conventional. This is known as waiting periods wrt mortgage underwriting guidelines. Credit score might impact the rate, but on the property ladder might be than not, have to model both ways (appreciation, cost of debt service, reserves, rent, etc).
(Strategically defaulted on property after buying at the peak before 2008 GFC)