Home

SPFx Extension: Retrieve associated hub site

%3CLINGO-SUB%20id%3D%22lingo-sub-877230%22%20slang%3D%22en-US%22%3ESPFx%20Extension%3A%20Retrieve%20associated%20hub%20site%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-877230%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20all%2C%3CBR%20%2F%3E%3CBR%20%2F%3EI'm%20fairly%20new%20to%20SPFx%2C%20so%20please%20be%20kind.%3CBR%20%2F%3E%3CBR%20%2F%3EI'm%20trying%20to%20achieve%20a%20fairly%20simple%20extension%20that%20works%20a%20little%20bit%20like%20a%20breadcrumb.%20Basically%2C%20it's%20a%20list%20containing%20three%20items%3A%3CBR%20%2F%3E%26gt%3B%20Title%20of%20the%20page%20you%20are%20currently%20on%3CBR%20%2F%3E%26gt%3B%20Site%20collection%20of%20that%20page%3CBR%20%2F%3E%26gt%3B%20Associated%20Hub%20site%3CBR%20%2F%3E%3CBR%20%2F%3EFor%20the%20time%20being%2C%20that%20has%20to%20be%20enough.%20I've%20managed%20to%20get%20the%20page%20and%20site%20collection%20fairly%20easily%20by%20using%20the%20pageContext.%20However%2C%20I%20am%20struggling%20to%20get%20the%20associated%20Hub%20site%20as%20well.%3CBR%20%2F%3E%3CBR%20%2F%3EI%20have%20been%20able%20to%20generate%20the%20Hub%20site%20id%20(by%20using%20the%20legacyPageContext)%2C%20but%20now%20I%20am%20stuck.%20Can%20I%20retrieve%20a%20site%20by%20its%20ID%3F%20And%20can%20I%20select%20the%20Title%20of%20that%20page%3F%3CBR%20%2F%3E%3CBR%20%2F%3EPlease%20forgive%20me%20if%20this%20is%20a%20really%20stupid%20question.%20As%20I%20said%2C%20I'm%20just%20dipping%20my%20toes%20into%20the%20SharePoint%20development%20world.%3CBR%20%2F%3E%3CBR%20%2F%3EPS%3A%20Any%20other%20ideas%20that%20would%20get%20me%20a%20similar%20result%20are%20appreciated%20%3A)%3C%2Fimg%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-877230%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExtension%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EHub%20Site%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EIcon%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESPFx%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Highlighted
Regular Visitor

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 :)