The explosion of what North Korea said was an advanced hydrogen bomb came just days after it fired a missile over Japan and a few hours after Trump spoke with Japanese Prime Minister Shinzo Abe by phone about the "escalating" nuclear crisis.
Trump, who said after last week's missile launch that talking to Pyongyang "is not the answer", tweeted that Sunday's test showed North Korea's "words and actions continue to be very hostile and dangerous to the United States".
China had tried but failed to solve the problem, he said, while what he called South Korea's "talk of appeasement" would not work as "they (the North Koreans) only understand one thing!".
Russia struck a more cautious tone.
"In the emerging conditions it is absolutely essential to keep cool, refrain from any actions that could lead to a further escalation of tensions," Russia's foreign ministry said, adding that North Korea risked "serious consequences".
Moscow said talks were the only way to resolve the crisis. Later on Sunday, Russian President Vladimir Putin was set to meet his Chinese counterpart Xi Jinping in China.
Britain's foreign minister Boris Johnson called the nuclear test "reckless" and a "provocation".
"They seem to be moving closer towards a hydrogen bomb which, if fitted to a successful missile, would unquestionably present a new order of threat," he told Sky news, adding that there were no palatable military solutions.
French President Emmanuel Macron urged the United Nations Security Council to act.
"The international community must treat this new provocation with the utmost firmness, in order to bring North Korea to come back unconditionally to the path of dialogue and to proceed to the complete, verifiable and irreversible dismantling of its nuclear and ballistic programme," he said in a statement.
The International Atomic Energy Agency, which has no access to North Korea, called the nuclear test, Pyongyang's sixth since 2006, "an extremely regrettable act" that was "in complete disregard of the repeated demands of the international community."