State law determines the order of priority, if you don't have a will/trust, which is called dying "intestate".
In community property states, the community property (CP) goes all to the spouse. A 401k fund and most pensions are CP, at least to the extent that the funds/pension were earned during the marriage. There are some categories retirement benefits that are not CP.
Separate property goes spouse, kids, and I don't remember who else, according to statute. Here is a summary of CA law:
Intestacy Chart