In our analysis of real-world data of 13,887 individuals, the risk of cancer was significantly higher in patients with PID/SID or SOT/HSCT relative to patients who received TNF-i therapy while controlling for other predictors of cancer risk. Here, TNF is linked to cancer.