SPFx Extension: Retrieve associated hub site

Copper Contributor

Hi all,

I'm fairly new to SPFx, so please be kind.

I'm trying to achieve a fairly simple extension that works a little bit like a breadcrumb. Basically, it's a list containing three items:
> Title of the page you are currently on
> Site collection of that page
> Associated Hub site

For the time being, that has to be enough. I've managed to get the page and site collection fairly easily by using the pageContext. However, I am struggling to get the associated Hub site as well.

I have been able to generate the Hub site id (by using the legacyPageContext), but now I am stuck. Can I retrieve a site by its ID? And can I select the Title of that page?

Please forgive me if this is a really stupid question. As I said, I'm just dipping my toes into the SharePoint development world.

PS: Any other ideas that would get me a similar result are appreciated :)

0 Replies