The earthquake struck about 2km from the nearest town of Progreso in Panama. (Representational)

A 6.3 magnitude earthquake hit the Panama-Costa Rica border around midnight on Tuesday, the US Geological Survey said, with the potential to cause casualties and "significant damage".

The shallow quake struck at a depth of 10 kilometers (6 miles), about two kilometers from the nearest town of Progreso in Panama, USGS said.

There were no immediate reports of damage or casualties, but US seismologists said the disaster was "potentially widespread," with the USGS website pointing out that "past events with this alert level have required a regional or national level response."

"Estimated economic losses are 0-4 percent GDP of Panama," the website said.

According to the National Seismological Network (RSN) in Costa Rica, the quake struck at 0523 GMT Wednesday (11.23 pm Tuesday) with its epicenter located 11 kilometers east of the Panamanian border town of Puerto Armuelles.

The tremor was felt in Costa Rica's capital San Jose and in many parts of the Central American country, according to initial reports, but the national tsunami warning system said there was no risk of a tsunami.

In November 2017 a 6.5-magnitude quake on the Pacific coast of Costa Rica caused buildings to sway in San Jose and contributed to the deaths of two people who had heart attacks.

Further north, two months earlier a 7.1-magnitude earthquake killed more than 300 people in Mexico.