Hurricane Dorian was barreling toward the US coastline Wednesday night and could strengthen into a Category 3 storm by the time it hits the mainland as early as this weekend, forecasters said.

Puerto Rico was largely spared Dorian’s worst, with the squall changing course and just grazing the eastern edge of the island before heading into open water.

But that could spell trouble for Florida, where Gov. Ron DeSantis declared a state of emergency Wednesday.

“All Floridians on the East Coast should have 7 days of supplies, prepare their homes & follow the track closely,” DeSantis said on Twitter.

County governments along the Sunshine State’s east-central coast began distributing sandbags, while residents flocked to warehouse retailers for canned food, water and supplies.

Dorian strengthened Wednesday from a tropical storm to a Category 1 hurricane — meaning winds between 74 and 95 mph — and will have little in its path to slow it down now as it churns over the warm waters of the Atlantic basin at 14 mph, according to experts.

“The Virgin Islands is the only thing it’s really interacting with and that’s not going to be a big deal,” AccuWeather meteorologist Jake Sojda told The Post.

“Right now it’s looking like it’s going to stay over open water pretty much for its whole entire life before making landfall, and now the expectation is that this is going to become a major hurricane,” he added.

Forecasters say the storm will reach Category 3 — meaning gales of up to 129 mph — before it hits the US coast, according to AccuWeather.

Despite not hitting Puerto Rico head-on, Dorian still brought high winds and heavy downpours to the island, with up to eight inches of rainfall in portions of the east side of the US territory.

Puerto Ricans — who have not fully recovered from 2017’s Hurricane Maria, which killed nearly 3,000 people and inflicted more than $90 billion worth of damage — had prepped for the worst.

“Heavy rainfall over portions of Puerto Rico and the Virgin Islands could produce flash flooding through Thursday morning,” the National Hurricane Center said.

Authorities reported one storm-related fatality in the US territory, where an 80-year-old man fell to his death from his roof while trying to storm-proof his home Wednesday.

Dorian also entirely missed the larger island of Hispaniola.

Forecasters said earlier in the week that some of Dorian’s strength would have been sapped had it gone over the island, which is home to the Dominican Republican and Haiti.

But a tropical storm warning that had been in effect was lifted early Wednesday when the storm shifted north and toward the US.

With Wires