Credit: Joan Marcus

Yes, it’s Hamlet — but the play’s not really the thing in Theresa Rebeck’s bright, lushly executed showpiece. It’s the first half of her slashed equation: Sarah Bernhardt.

With only a handful of flickering short films and scratchy audio left to go on from more than a century ago, it’s hard to know firsthand exactly what made the French-born actress, nicknamed “the Divine Sarah,” such a sensational star. Arguably the most celebrated artist of her era if not beyond, she didn’t just play legendary women onstage — Cleopatra, Medea, Joan of Arc — but became one off of it, too: taking scandalous lovers, sleeping in a satin-lined coffin, spending money like water.

It’s enough to know, in other words, that the actress who inhabits her in Bernhardt/Hamlet has serious shoes (or more specifically, suede thigh-high riding boots) to fill. And when Janet McTeer strides in, she feels completely right. Not because the Tony winner and Oscar nominee necessarily resembles her muse: Blond, British, and over 6 feet tall, she hardly could. But at 57, she crackles with the vitality, sensuality, and flytrap wit of a genuinely lived-in diva. And, of course, the vanity: “No one upstages me,” she coos early on, batting away even the idea with a wave of her hand.

Not even Shakespeare, apparently; after years of Ophelia, Bernhardt has decided, as the play opens, to take on the title role in one of the Bard’s best known works. Though it may take a while for the idea to sink in: “Who’s her Hamlet?” a sniffy critic asks, perplexed. “She’s her Hamlet,” her lover Edmond Rostand (Jason Butler Harner) explains patiently.

Edmond, a respected playwright in his own right (if also a perpetually tortured one), isn’t exactly sure she should be taking on the role; she’s had a bad run financially, and she needs a hit. What wide 19th-century audience, even one that adores her, will readily accept this kind of gender transgression?

Writer Rebeck (Seminar) and director Moritz von Steulpnagel (Present Laughter) keeps the action moving with brisk, chamber-piece choreography: The ingenious set (by Tony winner Beaowulf Borrit) makes the most of its two-plus sides, and supporting players (including Brittany Bradford and Dylan Baker as a bobbling fellow thespians and Nick Westrate as Sarah’s grown son) swan around in Toni-Leslie James’s dazzling costumes — crisp britches and white linens, richly piled velvets and shimmering silk.

The drama is essentially all backstage stuff, brought to center stage: Sarah and Edmond’s conflicted love affair, complicated further by Sarah’s demand that he trim the excess “poetry” from Hamlet for her; theater-troupe shenanigans in dusty rehearsal halls and opulent dinner parties brimming with secret flirtations and drunken debates.

The glue in it all is McTeer. Whether striding across the stage in her princely Danish pants or reclining languidly in a belle epoque gown, she’s a natural force beneath her leonine pile of gold curls — by turns anxious and imperious, vulnerable and funny and fierce. She’s also the best, most vivid thing in nearly every scene: No one’s note-perfect Hamlet maybe, but above all to her own self (and, you’d like to imagine, Sarah’s too) true. B+