Image copyright Getty Images Image caption California has stayed ahead of the curve

After a resident of California died of coronavirus on 4 March, Governor Gavin Newsom declared a state of emergency. It was the first Covid-19 related death in the US outside of Washington state.

More than 24,424 people have tested positive for coronavirus in California and 821 people have died. Yet the losses, while tragic, are a fraction of what experts predicted the state's 40 million people would face.

The virus is spreading fast in southern California and the state's Central Valley - so it's not out of trouble yet.

But considering the dire prediction made by Governor Gavin Newsom in March that up to 25 million Californians could be infected with coronavirus, the situation in California has been surprisingly well controlled.

State officials maintain they think the virus will peak in mid-May. Others think California could reach its peak this week.

The University of Washington's Institute for Health Metrics and Evaluation projected in March that more than 6,000 people in California would die of coronavirus. This week, the institute revised their forecast - projecting that California will reach its peak on 17 April - with 1,783 deaths.

California has only tested 212,900 people - and not all of the tests have been processed - so the number of confirmed cases will likely be considerably higher. But the death rate is much lower than many expected.

So why is California faring so much better than many predicted?

The state acted early

California was the first place in the United States to issue shelter in place orders. Gov Newsom ordered California to shelter in place on 19 March - three days before New York.

The statewide order followed similar ones issued on 16 March by several Bay Area counties and cities - including San Francisco.

Residents were urged to stay home and only go to essential businesses, like grocery stores and pharmacies, when necessary.

But can a day or two really make that much difference? "Oh yes," said Dr Neha Nanda, the medical director of infection prevention and antimicrobial stewardship at Keck Medicine, University of Southern California.

"Even being one day ahead can have a huge impact," she told the BBC. "The morbidity we will be able to avert, the mortality we will be able to avert - it's huge."

Because so little is known about the virus or how it can be treated, it makes prevention "more important than anything else," she said. "The most potent tool that you have in tool kit is social distancing."

The authorities took it seriously

On 9 March, Santa Clara county banned gatherings of more than 1,000 people. The ban came hours after a woman died in Santa Clara county. Soon, the limits on gatherings of 1,000 people became limits on groups of 50 people.

Many were shocked at the time about what limited gatherings would do to sports teams and musical and theatrical events.

But this didn't deter local officials - and San Francisco Mayor London Breed, Los Angeles Mayor Eric Garcetti and Oakland Mayor Libby Schaaf announced bans on gatherings several days later.

"Our first priority remains the health, safety and wellbeing of all Oaklanders, as well as those who visit our city," Mayor Schaaf said at the time.

"Although there are no known positive cases of Covid-19 within Oakland right now, postponing large gatherings will help prevent the spread of the virus. We take these measures to prepare and protect our community and ground our decisions in facts, not fear."

Media playback is unsupported on your device Media caption US death rates v China, Italy and South Korea

At the time it was inconceivable that e-sports would replace live sports and concerts would be staged on living room couches and filmed on phones.

"We've been proactive," Dr Nanda said, and a result "we have not seen that huge uptick".

The population is more spread out

Unlike densely packed New York where most people rely on public transportation, California is known for its urban sprawl and its love affair with the car.

New York City is three times as dense as the city of Los Angeles. And although Los Angeles County has more than 10 million people, many more Angelenos drive cars than New Yorkers.

According to a UCLA study from 2018, fewer than 3% of people in Southern California ride public transport frequently.

UCLA epidemiologist Dr Timothy Brewer said our urban sprawl may be helping stop the virus from spreading faster than in cities like New York or Detroit.

"We certainly don't have the population density of New York City," Dr Brewer said. "The less dense the population, the more easy it is to maintain physical distances from each other."

But Dr Brewer said he thinks it was California's aggressive social distancing policies put in place early that account for most of the state's success so far.

California could well have had more cases "had they followed a similar trajectory as New York, New Jersey or some other locations in the United States" when it came to social distancing, he added.

Beaches and hiking trails are closed

The state initially got off to a bumpy start when it came to public spaces.

The weekend of 15 March sent many Californians panic shopping for seemingly all the toilet paper, yeast and sourdough bread flour in the state, and the following weekend saw Californians flocking to the state's beautiful beaches and hiking trails.

Beaches were packed. Popular trails like Runyon Canyon in LA were more crowded than ever making social distancing impossible.

Eventually, officials closed beaches and hiking trails throughout the state and urged people to walk in their own neighbourhoods.

Image copyright Getty Images Image caption Authorities have closed piers and beaches

Sometimes the authorities enforce the rules - though not consistently.

California was ridiculed on Fox News after video emerged of multiple boats involved in the arrest of a lone paddle-boarder in Malibu who defied lifeguard warnings to leave the water. Wet weather in Los Angeles meant snow in the local mountains and two snowboarders were caught sneaking onto the slopes.

Officials across the state say they'd rather not enforce the rules - but they will crack down on scofflaws.

Some tickets have been issued across the state. In San Diego, homeless advocates have objected to the ticketing and arrest of homeless people for sleeping in the streets.

And in Los Angeles, Mayor Garcetti encouraged people to "snitch" on anyone violating the shelter-in-place order, or operating businesses not considered essential.

"You know the old expression about snitches, well in this case snitches get rewards," Mayor Garcetti said earlier this month. "We want to thank you for turning folks in and making sure we are all safe."

Many people criticised the mayor's snitch policy, and it's not clear how many people have reported infractions.

But California's leaders have mostly been applauded for acting early to control the virus.