President Barack Obama, in the days following the November 2016 election, began to question his own legacy.

The aftershock of Donald Trump's surprise victory over Hillary Clinton had shaken Obama, as it did many others. At one point, America's first black president had wondered whether his election had come "10 or 20 years too early."

Those were some of the confessions outlined in an upcoming memoir, "The World as It Is," written by the longtime Obama adviser, Ben Rhodes.

In the days following Donald Trump's surprise victory over Hillary Clinton in the 2016 US election, President Barack Obama questioned his own legacy and wondered whether he and his team had overestimated the strength of their electoral coalition.

Those confessions were outlined in the forthcoming memoir, "The World as It Is," from Ben Rhodes, one of Obama's longtime advisers.

The memoir shows that Obama was not immune to the collective shock that had followed Trump's election. Obama wondered whether he miscalculated the undercurrent of political angst brewing in middle America, which had helped fuel Trump's victory.

And as the first African-American president, who had won two terms — both of which he sealed with overwhelming electoral-college majorities — he also wondered if his own presidency had come "10 or 20 years too early."

In 2016, Trump campaigned on a nationalist agenda, frequently criticizing globalist policies he saw as detrimental to the US. The Paris climate accord and the Iran deal were some of Trump's targets, as were the policies that promoted immigration and welcomed refugees.

The tone of Trump's campaign earned him rebukes from both Republicans and Democrats who criticized his penchant for using racial animus to energize his base. According to Rhodes' memoir, Obama recalled those moments after the election, asking "Maybe people just want to fall back into their tribe."

Nearly two years into Trump's first term, Obama has been considerably quiet about the 45th president, despite frequent criticism from Trump and members of his administration.

Barack and Michelle Obama made headlines in May after signing on to produce shows and movies for Netflix. They each have their own memoirs in the works.