Lightning produces a brief, intense plasma channel that heats the surrounding air to approximately 30,000°C (54,000°F). According to Weather.gov and Britannica, this makes lightning about five times hotter than the Sun's surface, called the photosphere, which is around 5,500°C (10,000°F) as stated by NASA and Caltech.
While lightning's extreme temperature is highly localized and short-lived, the Sun's surface temperature is a stable, continuous condition. The comparison is accurate when referencing the Sun's surface only, not its much hotter core, which exceeds 15 million°C.
Multiple authoritative sources, including Weather.gov and NASA, agree on these figures. Therefore, it's correct to say lightning is hotter than the Sun's surface, even though the conditions and duration differ greatly.