LONDON — In his first interview since leaving the White House in January, former President Barack Obama told Britain's Prince Harry that the transition out of public office left him with a sense of "serenity."

The former U.S. president told listeners of BBC Radio's flagship morning news program, Today, that the end of his administration brought a sense of satisfaction "mixed with all the work that was still undone and concerns about how the country moves forward."

But, he said, "overall there was a serenity there, more than I would have expected."

In the wide-ranging interview — recorded at the Invictus Games in Canada in September but broadcast on Wednesday — Obama also warned of the dangers of social media dividing society and said healthcare reform was among his proudest achievements.

Obama said he was lucky to have been propelled into the spotlight in his 40s, at a time when he was already grounded. "When I got off the treadmill, it didn’t feel like my identity was wrapped up in having this position," he said.

The former president also paid tribute to his wife, Michelle, saying his transition from power was made easier by the fact that his marriage had been left "intact" and the couple felt they had "preserved our integrity."

Obama told Harry that the trials and tribulations of life in the public eye were worth the opportunity he was given to effect positive change — singling out healthcare reform as an example.

"What an enormous blessing it is to be able to say that 20 million people have health insurance that didn’t have it before. And even a fraction of those 20 million are leading better, healthier lives, are happier, some child is fulfilling their potential. That’s a pretty good scorecard," Obama said in the interview, which was overall light on political substance. "

Obama's comments come at a time when Republican lawmakers are continuing to battle to undo his healthcare policies.

Related: Trump claims Obamacare is ‘repealed,’ as GOP puts off aid to insurers

President Donald Trump boasted on Twitter Tuesday that the GOP tax bill he signed into law last week "essentially repeals" Obama's signature achievement, citing the bill's elimination of the individual mandate, which penalized Americans who go without health insurance.

While the mandate is a key component of the Affordable Care Act, the law's subsidies and regulations are still in effect.

Obama also warned of the dangers of social media. Though he did not mention Trump by name, he called on people in government to be careful in their use of platforms like Twitter.

"One of the dangers of the internet is that people can have entirely different realities. They can be cocooned in information that reinforces their current biases," he said.

While he emphasized his commitment to the First Amendment, Obama said society needed to find ways to harness technology so that it "doesn't lead to a 'Balkanization' of our society but rather continues to promote ways of finding common ground."

Obama said he didn't think government could legislate to ensure this happens, but that world leaders should promote commonality online rather than foster divisions.

"All of us in leadership have to find ways in which we can recreate a common space on the internet," he said.

Obama also called on young people to get off the internet and work to enact change in their communities, but he dismissed the often cited idea that millennials are selfish and superficial. “I haven’t found that, I haven’t seen it,” he told Harry, adding that the view was indicative of the disconnect between people who are comfortable with power as its currently exercised and those who are not.

“This generation coming up is the most sophisticated, the most tolerant in many ways, the most embracing of diversity, the most tech savvy, the most entrepreneurial but they don’t have much faith in existing institutions,” Obama said.

Related: Meghan Markle engagement to Prince Harry exposes 'quiet' racism

The interview was part of Prince Harry's guest-editorship of the BBC Radio program, in which he also interviewed his father the Prince of Wales.

Last month, Harry announced his engagement to American actress Meghan Markle. Speculation as to whether the couple would invite the Obamas swirled this week in anticipation of the interview.

When asked on the program Wednesday whether they would be among the guests at his wedding in May next year, Harry dodged the question. "I don't know about that ... Wouldn't want to ruin that surprise," he said.

Prince Harry knows how to dodge a difficult question (as well as how to ask them) Q - “You inviting Obama to the wedding ?” Harry - “I don’t know about that...Wouldn’t want to ruin that surprise” @BBCr4today — Nick Robinson (@bbcnickrobinson) December 27, 2017

Harry knows the Obamas through his organization of the Invictus Games, a competition for wounded, injured or sick armed services personnel.

Harry and the Obamas have made a number of joint appearances including during the Invictus Games in Toronto in September, when Obama and Harry were pictured together at a wheelchair basketball game.

In 2016, Michelle Obama helped Harry kick off that year's event, calling him "Prince Charming."

In addition to the more in-depth interview, Harry asked Obama a “lightning round” of questions of the type normally asked of entertainers, not politicians.

The former president declined to say whether he wears boxers or briefs, but was willing to say he prefers Aretha Franklin to Tina Turner — “Aretha is the best,” he said of the Queen of Soul — and favors retired basketball star Michael Jordan over current star LeBron James.