Abstract We study the stellar, neutral gas content within halos over a halo mass range 1010to1015.5M⊙ and hot X-ray gas content over a halo mass range 1012.8to1015.5M⊙ in the local universe. We combine various empirical datasets of stellar, H i and X-ray observations of galaxies, groups and clusters to establish fundamental baryonic mass vs halo mass scaling relations. These scaling relations are combined with halo mass function to obtain the baryon densities of stars, neutral gas and hot gas (T > 106K), as a function of halo mass. We calculate the contributions of the individual baryonic components to the cosmic baryon fraction. Cosmic stellar mass density ($\Omega _\text{star}=2.09^{+0.21}_{-0.18} \times 10^{-3}$), cosmic H i mass density ($\Omega _\rm{H\,{\small I}}=0.49^{+0.25}_{-0.12} \times 10^{-3}$) and cosmic neutral gas mass density ($\Omega _\text{neutral gas}=0.71^{+0.39}_{-0.18} \times 10^{-3}$) estimates are consistent with previous more direct method measurements of these values, thereby establishing the veracity of our method. We also give an estimate of the cosmic hot plasma density ($\Omega _\text{hot gas}=2.58^{+2.1}_{-0.66} \times 10^{-3}$).