Cynthia Erivo was downstairs at the Bernard B. Jacobs Theater last Sunday, preparing for her final performance as Celie in the Broadway show “The Color Purple.” By now, she was used to the muffled noise of theatergoers slipping into their seats before the show began. But this afternoon the clatter was altogether different. First there was a rumble of heavy footsteps, followed by a burst of applause and cheers that reverberated deep into the theater’s subterranean dressing rooms and lasted nearly 10 minutes. Someone famous had arrived. And Ms. Erivo knew who it might be.

“Hillary’s in the building,” she told a colleague.

Hillary Clinton and former President Bill Clinton were winding their way to their seats through a crush of well-wishers, including Gayle King, Debra Messing and the Vogue editor Anna Wintour, many of whom clapped and shouted “We love you, Hillary,” and “God bless you.” Onlookers captured the racket on their iPhones as Mrs. Clinton waved and posed for selfies. Ms. Erivo had invited the couple (via a Clinton staff member the actress knew) to see “The Color Purple” weeks after Mrs. Clinton’s defeat in the November presidential election.

“I thought this might be a wonderful thing for her,” Ms. Erivo said in an interview on Tuesday. “It’s healing — a way for her to forget for an evening.”