Despite being particularly vulnerable to the novel coronavirus in the United States, Chinatown turned out to be well-prepared, unlike other places around the country. Chinese Hospital was at the center of an effort to coordinate barriers for entry of the virus. These involved almost every major institution in Chinatown, including the Chinese-language press and deeply engaged neighborhood institutions, all of whom were imprinted with memories of earlier infectious disease outbreaks. Deep links to front-line health workers in China would also be invaluable as Chinese Hospital worked to avoid what everyone thought was coming.

[See our map of coronavirus cases in California by county.]

Given the unpredictable pathways of this highly contagious disease, Dr. Zhang and other leaders in Chinatown are well aware that circumstances could change in an instant. Compliance with shelter in place has at times been haphazard. (Mr. Peskin’s office has fielded many complaints about card games in Chinatown’s Portsmouth Square.) But the successes so far can be traced to early action by hospital and community leaders to keep the virus out of areas where it might otherwise flourish.

On Feb. 1, one week after Chinese New Year, Dr. Zhang, Mr. Peskin and Chinatown community leaders hosted a news conference highlighting practices to slow the spread of the virus. The Chinese Consul General in San Francisco gave an update on the Chinese government’s response.

More than 15 years earlier, many in the community had family members who experienced the outbreak of SARS in China, a memory that Dr. Zhang and others said made them more receptive to the advice from local leaders.

In early February, the principal of Central Chinese High School announced an initiative to sterilize classrooms and encouraged teachers and students recently in China to stay home for a 14-day self-quarantine. By mid-February, the Chinatown Community Development Center, the owner of 11 S.R.O.s housing several hundred tenants, had installed hand sanitizers in their buildings, doubled up on daily cleanings and started educating tenants about basic hygiene principles.

Mr. Peskin saw the effects of this informal campaign every day when he drove through Chinatown on his way to City Hall. “For a while it was kind of startling that on one side, on the north side of Broadway, everything was ‘normal’ and nobody was wearing masks,” he said. “And the second you would cross Broadway into Chinatown, everybody was wearing masks.”

Nonetheless, the perception of Chinatown as a potent hotbed of the coronavirus quickly took hold. In February, well before a single Covid-19 case had been detected in San Francisco, tourism in Chinatown evaporated. On Jan. 31, President Trump had announced travel restrictions to and from China, and before long he was referring to “the Chinese virus.” Attacks against Asian-Americans jumped nationwide.