Sign up for our special edition newsletter to get a daily update on the coronavirus pandemic.

New York City is now the epicenter of the coronavirus pandemic in the United States. As of Thursday, there were some 160,000 confirmed cases of COVID-19 in New York state and more than 7,000 deaths — 43 percent of the ­national toll. Most of these cases have occurred in Gotham and its suburbs.

Other urban areas, however, have performed much better than we have. The Bay Area, for example, has about the same population as New York City, but only 115 deaths from the coronavirus. San Francisco proper has seen only 10 deaths so far, about 2 percent of the per-capita rate in New York.

New York and San Francisco are both major urban centers, so why did we do so much worse? Why are their infection rates so different? New York’s density is likely one part of it. As is the fact that the Big Apple receives many more visitors from abroad. But leadership is a big part of the equation, too.

While Mayor Bill de Blasio was slow and indecisive, San Francisco’s Mayor London Breed ­exemplified proactive leadership when it mattered most — at the outset.

Start with de Blasio’s failures. Medical researchers have widely recognized that schools turbocharge epidemics: Crowded together, children spread disease, often without falling ill themselves. Yet Hizzoner kept New York’s schools open through early March, even when most other urban districts had closed, students in our schools had fallen ill and teachers and administrators pleaded for closure. Schools Chancellor Richard Carranza arrogantly dismissed a petition with 108,000 signatures demanding the schools be closed.

Even as other cities began taking increasingly drastic measures to slow the outbreak, de Blasio failed to take the crisis seriously. He was furious that the city’s libraries planned to close and threatened to cut their budget in response, ­according to Politico reporting.

He refused to cancel the St. Patrick’s Day parade, claiming that the virus required “close physical proximity” beyond the level of a parade crowd to spread, until the governor intervened. And the day before bars, gyms and restaurants closed statewide, Hizzoner took a final trip to his own gym and urged New Yorkers to go out to local restaurants for one last night on the town.

Now compare Frisco. The Golden City’s first case appeared on March 5, about the same time as the first one in New York. But San Francisco’s leaders took the disease seriously from the start.

In late February, even before any cases had been identified within city limits, Breed ­declared a state of emergency. On March 16, health officials throughout the Bay Area issued a shelter-in-place order, closing all but essential businesses. The state government had already banned large gatherings four days before that.

That proactiveness bought time. “We were maybe a week up on New York,” one UC Berkeley public-health expert told the San Francisco Chronicle. “That doesn’t sound like much time, but in terms of the spread of this pandemic, it’s enormous.” ­Indeed.

And San Francisco has a much lower infection rate than its low-density suburbs such as Santa Clara County — not to mention other sprawling metropolitan areas such as Detroit and New Orleans.

Proactive leadership has yielded dividends elsewhere, too. Kentucky Gov. Andy Beshear, for example, took statewide measures against the spread of coronavirus much sooner than neighboring Tennessee did, including advising a statewide closure of schools more than a week earlier.

The result: Though the first cases in both states appeared at about the same time, Kentucky, with only two-thirds the population of Tennessee, has one-fifth of the coronavirus cases. In northern Italy as well, towns that ­imposed early quarantine measures and shutdowns escaped the worst of the contagion.

When it comes to leadership in a crisis — especially one of public health — proactiveness pays off. De Blasio may have worried about being called alarmist if he had imposed a shutdown in early March.

Whatever the cause, that week of delay has now exposed New York to far worse. Meanwhile, Breed acted early and decisively, even when the public still didn’t see the virus as a serious threat, and San Francisco is better off for it. Fortune, as the Latin proverb goes, favors the bold. Doubly so in a crisis.

Connor Harris is a policy analyst at the Manhattan Institute.