NEW YORK — Kevin Smith tweeted fans early Monday that he had suffered a “massive heart attack” after shooting a comedy special in the Los Angeles area.

“If I hadn’t canceled show 2 to go to the hospital, I would’ve died tonight,” Smith tweeted from the hospital. “But for now, I’m still above ground!”

Smith, the 47-year-old filmmaker (”Clerks,” “Mallrats,” “Chasing Amy”), writer and star of the AMC reality series “Comic Book Men,” was reportedly between shows being filmed for a new standup special in Glendale, California, when he was stricken. Smith had posted on Facebook hours earlier about his show taping.

Smith, who shoots “Comic Book Men” in his native Red Bank, N.J., recently appeared in the 2017 film “Disaster Artist” and had directed recent episodes of CW’s “The Flash” and “Supergirl.” Smith also has written comics for such characters as Daredevil, Green Hornet and Batman.

As a performer, Smith debuted his Silent Bob character in “Clerks” as a mute comic foil to fellow slacker Jay, played by Jason Mewes. Smith told The Washington Post’s Comic Riffs in 2013 that the film was “a benchmark of his sobriety,” referring to his longtime friend Mewes, who had battled addictions to heroin and OxyContin.

Fans and fellow celebrities, including Chris Pratt, tweeted their concern and wishes to Smith early Monday.

“Praying for you. I will continue to. You inspired me with ‘Clerks’ when I was a senior HS. I’m tagging my Lb/rb football coach who showed me the movie cause he believed in me and knew I’d be inspired,” Pratt wrote on Twitter.