CNN  — 

The Grand Princess cruise ship floated for days off the coast of San Francisco in early March like an omen to a coming disaster.

“We could see it from our windows,” said Dr. Robert Wachter, professor and chair of the Department of Medicine at University of California, San Francisco. “That made it real.”

It was one early warning sign that would prompt California to take extraordinary steps to slow the spread of coronavirus, especially after the White House announced that 21 people aboard the cruise ship had tested positive for Covid-19.

Within weeks, Gov. Gavin Newsom issued the first statewide mandatory restrictions in the United States, ordering California’s nearly 40 million residents to stay home to help combat the outbreak.

California and New York – the nation’s hardest hit state – had about the same number of coronavirus cases in the first week of March, according to Covid Tracking Project.

By Friday, California had 11,889 cases compared to nearly 10 times that in New York, or 102,985 cases. The Golden State has 264 deaths to New York’s 2,935.

“When we write this history and look at the tens of thousands of lives in California that will have been spared, I think there will be lots of factors that went into it,” Wachter said.

“But I do believe the most important was that leaders of all types – whether they were in government or in businesses – took it seriously, believed that this was a real risk and did the right thing early.”

Here is what California did right in response to the contagion:

Silicon Valley employees started working from home

LOS ANGELES, CALIFORNIA  - MARCH 25: People maintain social distancing while standing in line to enter a Trader Joe's as the coronavirus pandemic continues on March 25, 2020 in Los Angeles, California. California Governor Gavin Newsom issued a 'stay at home' order for California's 40 million residents in order to slow the spread of COVID-19. Los Angeles. (Photo by Mario Tama/Getty Images)
California braces for wave of coronavirus cases
02:33 - Source: CNN

In early March, health officials in northern California were recommending that companies allow employees to work work from home. Employers were urged to stagger starting and closing times. Companies were asked to suspend nonessential travel.

Apple encouraged its Silicon Valley employees to work from home, according to a company spokesperson. Its Seattle employees also began working remotely.

The iPhone maker’s headquarters is in Cupertino. It also has offices in Santa Clara.

“So much of the businesses, particularly in northern California, are the tech businesses. And companies like Google and Apple and Salesforce and others told their employees to work from home as early as March 5,” Wachter said.

“There was a general sense here that this is serious stuff, that the experts are telling us we need to do this. And people listened.”

San Francisco Bay area issues shelter-in-place order

A man crosses a nearly empty street in San Francisco, Tuesday, March 17, 2020. Officials in seven San Francisco Bay Area counties have issued a shelter-in-place mandate affecting about 7 million people, including the city of San Francisco itself. The order says residents must stay inside and venture out only for necessities for three weeks starting Tuesday. (AP Photo/Jeff Chiu)
Streets empty as San Franciso is ordered to shelter in place
02:27 - Source: CNN

In one of the most draconian measures at the time, nearly seven million people across a wide swath of Northern California, including Silicon Valley, were ordered to shelter in place effective March 16.

Along with San Francisco, residents in San Mateo, Santa Clara, Marin, Alameda, and Contra Costa counties, as well as the city of Berkeley, were required to stay home, per orders from health officers in those jurisdictions.

Health services, grocery stores, gas stations, banks and food delivery services remained open. Mass transit stayed open but was to be used only for travel to and from essential services.

“That was no accident,” Dr. George Rutherford, professor of epidemiology at the University of California San Francisco, said of the timing of the order. “It was the day before St. Patrick’s Day which is a huge mixing event as you can imagine.”

San Francisco instituted a number of initiatives to help those out of work or otherwise hurt by the lockdown, including grants for small businesses.

Lead Mayor London Breed Live_00034804.jpg
SF Mayor: More than 7 million people in Northern California urged to shelter in place
04:41 - Source: CNN

“Why people are praising San Francisco is because everyone here knew how important it was to follow instructions and … that is what is going to get us through, make us successful, keep us safe,” San Francisco Mayor London Breed said Friday.

Weeks after San Francisco issued the country’s first shelter-in-place order for residents, hospital emergency rooms throughout the region appear to be seeing the early effects.

“The surge we have been anticipating has not yet come,” Dr. Jahan Fahimi, an emergency physician and medical director at the University of California San Francisco, said this week. “We’re all kind of together holding our breaths.”

As of Friday, the city reported 497 confirmed infections and seven deaths from the coronavirus. And while the availability of testing is still much lower than officials would like, the modest daily count compared to other major urban centers is a sign that early action in the country’s second most densely populated city had an impact.

“This is what a flat curve looks like,” Wachter said Friday. “And I think everybody’s a little reluctant to talk about it too much because we’re really hoping our good fortune continues and we’re absolutely hoping that people don’t change their behavior too soon.”

Governor issues early statewide stay-at-home order

LOS ANGELES, CA - NOVEMBER 06: Democratic gubernatorial candidate Gavin Newsom speaks during election night event on November 6, 2018 in Los Angeles, California. Newsom defeated Republican Gubernatorial candidate John Cox. (Photo by Kevork Djansezian/Getty Images)
California governor orders residents to stay at home
00:55 - Source: CNN

Under the statewide order issued March 19, Californians should not leave home except for essential things such as food, prescriptions, health care and commuting to jobs considered crucial.

“This is a moment where we need some straight talk,” Newsom told reporters at the time. “As individuals and as a community, we need to do more to meet this moment.”

Essential services such as groceries, pharmacies, gas stations, farmers markets, food banks, convenience stores and delivery restaurants remained open. As did banks, local government offices that provide services and law enforcement agencies.

Nonessential services such as dine-in restaurants, bars, gyms and convention centers shut down under the order.

New York state did not issue a stay-at-home order until March 20. It took effect two days later.

Wachter added, “Southern California is somewhat worse than Northern California but still a far, far cry from New York and New Jersey and Michigan. And what we’re beginning to see in Florida.”

The Los Angeles County Department of Public Health on Friday reported 4,566 cases, with 89 deaths.

Health department director Dr. Barbara Ferrer said Friday the county expects 1,000 new cases or more per day as it reaches its goal of testing 10,000 people a day.

This week, Los Angeles Mayor Eric Garcetti urged residents to wear non-medical grade face coverings when in public. President Donald Trump on Friday evening announced his administration was recommending Americans wear “non-medical cloth” face coverings.

Dr. Robert David Siegel, a professor in the Department of Microbiology and Immunology at Stanford University, said California was also aided in stemming the virus’ spread by strong and early public health awareness campaigns and a sprawling demography compared to places like New York City.

Wachter said California’s efforts have been bold and controversial but appear to be working.

“There were people that said, ‘Why are you doing this? You’re going to kill the economy,’” he said. “I think there’s just a general attitude – let’s trust the science, if this is what the science tells us, we need to take it very seriously.”

CNN’s Cheri Mossburg contributed to this report.