SPFx Application Customizer: Adding Headers and Footers

On this page

Application Customizers let you add global headers and footers to SharePoint pages. Perfect for branding, notices, or navigation.

Create the Extension

Bash3 lines
yo @microsoft/sharepoint
# Select Extension
# Select Application Customizer

Using Placeholders

TypeScript22 lines
import { BaseApplicationCustomizer, PlaceholderName } from '@microsoft/sp-application-base';

export default class HeaderFooterCustomizer extends BaseApplicationCustomizer {
  
  public onInit(): Promise {
    this.context.placeholderProvider.changedEvent.add(this, this._renderPlaceholders);
    return Promise.resolve();
  }
  
  private _renderPlaceholders(): void {
    const top = this.context.placeholderProvider.tryCreateContent(PlaceholderName.Top);
    const bottom = this.context.placeholderProvider.tryCreateContent(PlaceholderName.Bottom);
    
    if (top) {
      top.domElement.innerHTML = '<div class="header">Welcome Banner</div>';
    }
    
    if (bottom) {
      bottom.domElement.innerHTML = '<div class="footer">© 2019 Our Company</div>';
    }
  }
}

Deployment

After deployment, activate the extension tenant-wide or per-site using PowerShell or the CLI for Microsoft 365.


Discover more from C4: Container, Code, Cloud & Context

Subscribe to get the latest posts sent to your email.

Written by

Nithin Mohan TK

Hello Namaste! 👋🏻 I'm an accomplished Enterprise Solution Architect & Engineering Leader with 20+ years of progressive experience architecting, building, and scaling transformative enterprise solutions. ⚜️ Solution Architect / AI & Cloud 📌 Galway, Ireland

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.