The U.S. headed into the Fourth of July weekend with many parades and fireworks displays cancelled, beaches and bars closed, and health authorities warning that this will be a crucial test of Americans' self-control that could determine the trajectory of the surging coronavirus outbreak.

With confirmed cases climbing in 40 states, governors and local officials have ordered the wearing of masks in public, and families were urged to celebrate their independence at home. Even then, they were told to keep their backyard cookouts small.

"This year is a huge bummer, to say the least," said Ashley Peters, who for 14 years has hosted 150 friends and relatives at a pool party at her home in Manteca, California, complete with a DJ, bounce house, water slide and shaved-ice stand. This time, the guest list is down to just a few people.

Pulling the plug on the bash, she said, was a "no-brainer" because so many of those she knows are front-line workers, including her husband, a fire captain. "I woke up and told my husband I wish it was just July 5," she said.

Health experts agree this will be a pivotal moment in determining whether the nation slides into a deeper mess. The fear is that a weekend of crowded pool parties, picnics and parades will fuel the surge.

"We're not going to be arresting people for having gatherings, but we're certainly going to discourage it," said Dr. Jeff Duchin, public health director for Seattle and King County.

Those who decide they must gather with a small group of family members need to be careful, he said: "Don't share utensils, don't share objects, don't pass them back and forth, because you're passing that virus around as well."

The warnings were sounded after a Memorial Day weekend that saw many people emerge from stay-at-home orders to go to the beach, restaurants and family gatherings. Since then, confirmed infections per day in the U.S. have rocketed to an all-time high, more than doubling.

The U.S. set another record on Friday with 52,300 newly reported cases, according to the tally kept by Johns Hopkins University.

The picture was bleak around much of the country. In Arizona, the number of people in the hospital with a suspected or confirmed case of COVID-19 eclipsed 3,000 for the first time. Alabama reported more than 1,700 new confirmed cases, its highest single-day count yet. New York state, which has largely tamed the virus, recorded 918 new cases, the most in at least three weeks.

Despite it all, there will still be fireworks and community events scattered across the nation, with many taking social distancing into account. In Ohio, Upper Arlington's July Fourth parade will take a much longer route through its neighbourhoods so residents can watch without crowding the streets.

"We're calling it the front porch parade," said organizer Sam Porter. "We can't just not do something."

Fireworks will be launched from four spots across Albuquerque, New Mexico, so that people can ooh and aah from home instead of gathering in a single place.

Willie Nelson's annual Fourth of July Picnic will carry on at his Texas ranch outside Austin, but this year the concert portion will be virtual.

President Donald Trump travelled to South Dakota on Friday for a fireworks show at Mount Rushmore before returning to the nation's capital for military flyovers Saturday and a mile-long pyrotechnics display on the National Mall that his administration promises will be the biggest in recent memory. Up to 300,000 face masks will be given away but not required.

The big party will go on over objections from Washington's mayor.

"Ask yourself, do you need to be there? Ask yourself, can you anticipate or know who all is going to be around you? If you go downtown, do you know if you're going to be able to social distance?" Mayor Muriel Bowser said.

Beaches that had been open for the traditional start of summer over Memorial Day weekend will be off-limits in many places this time, including South Florida, Southern California and the Texas Gulf Coast.

The Centers for Disease Control and Prevention advised Americans who do go to the beach to wear face coverings, though not in the water.

With professional pyrotechnic displays cancelled, authorities are bracing for wildfires and injuries caused by Americans shooting off fireworks at home. Sales of fireworks have been booming in what some sellers say may reflect a desire for a little excitement among people cooped up for so long.

Jamie Parrott, a pediatric neurologist in Columbia, South Carolina, said he intends to stay home with his grandchildren, setting off fireworks and eating hamburgers, because that's the safer course for older people like him.

"We'll muddle through," he said.

Delaware's governor ordered bars in some beach towns to close, saying people were getting complacent about masks and social distancing. The Lake Erie resort village of Put-in-Bay in Ohio cancelled its fireworks after a small number of coronavirus cases were linked to bars on the island. And the New Jersey resort town of Wildwood did the same.

Still, many people are expected to pack the beaches, boardwalk restaurants and amusement parks up and down the Jersey shore.

South Carolina's Myrtle Beach is one of the nation's worst hot spots for COVID-19, and officials in several other states blame their outbreaks on vacationers returning from the resort city. On Thursday, the city passed a mask requirement.

"I hate the perception that people have right now, as any city would," said Mayor Brenda Bethune.

After hearing Michigan's governor warn about the need to be smart amid an uptick of cases, Mary Halley of Jonesville said her family cancelled plans for a weekend outing on Lake Michigan.

"We had some disappointed kids, but we knew as a family we couldn't do that," she said. The problem, she said, is that too many people aren't listening to the experts. "Even in my small, little town, there are lot of people who didn't comply with the orders," she said.

Dr. Don Williamson, head of the Alabama Hospital Association, said he is "really, really worried about the Fourth of July."

"I think that will likely determine the trend for Alabama for the rest of the summer," he said.

------

Associated Press reporters from around the world contributed to this report.