The molecular heterogeneity of cancer is one of the major causes of drug resistance that leads to treatment failure. Thus, better understanding the heterogeneity of cancer will contribute to more precise diagnosis and improved patient outcomes. Although single-cell sequencing has become an important tool for investigating tumor heterogeneity recently, it lacks the spatial information of analyzed cells. In this regard, spatial transcriptomics holds great promise in deciphering the complex heterogeneity of cancer by providing localization-indexed gene expression information. This study reviews the applications of spatial transcriptomics in the study of tumor heterogeneity, discovery of novel spatial-dependent mechanisms, tumor immune microenvironment, and matrix microenvironment, as well as the pathological classification and prognosis of cancer. Finally, future challenges and opportunities for spatial transcriptomics technology’s applications in cancer are also discussed.