HR asked me for a banner on every page of the company intranet: one line about open enrollment, a link to the details, and a footer with the help desk contact. Editing a hundred pages by hand wasn’t an option, and the old trick of injecting JavaScript into the master page doesn’t exist on modern SharePoint.
In this tutorial, we’ll build that banner as an SPFx application customizer with the Heft toolchain: a Top placeholder announcement bar and a Bottom placeholder footer with live office clocks. You’ll test it on a real page with the debug query string, then package it as an .sppkg file that’s ready for the app catalog.
Quick answer: Run yo @microsoft/sharepoint, pick Extension and then Application Customizer. In onInit(), subscribe to this.context.placeholderProvider.changedEvent and call tryCreateContent(PlaceholderName.Top) and PlaceholderName.Bottom to get a DOM element you can render into. Test with heft start and the debug URL, then run npm run build to create the .sppkg package.
| Tested with | Version |
|---|---|
| SharePoint Framework | 1.23.2 (Heft toolchain) |
| Node.js | 22 LTS (v22.22.2) |
| UI | Plain DOM + SCSS module (no React) |
| Editor | VS Code with its integrated terminal |
| Tested on | Modern page on /sites/SPGuides, 10/24/2026 |
What is an SPFx application customizer?
An application customizer is a SharePoint Framework extension that runs on every modern page where it’s registered.
It gives you two well-known spots: the Top placeholder (a strip at the top of the page, above the site header) and the Bottom placeholder (a footer strip at the bottom of the page). You can browse more SharePoint Framework guides on the SPFx tutorials hub.
You use it for things that belong on every page: announcement bars, cookie or privacy notices, global navigation, footers, analytics scripts and help desk links. Because SharePoint hands you the placeholder through an API, your banner keeps working when Microsoft changes the page HTML. Code that hunts for page elements by class name breaks the next time the layout changes.
Microsoft supports application customizers at the Site, Web and List scope. The scope depends on how you register it: a feature in the package (web level), the Tenant Wide Extensions list, or a custom action you add with REST, CSOM or PnP PowerShell.
Build the application customizer step by step
You need Node.js 22 LTS, Yeoman, the SharePoint generator and Heft installed globally. If you haven’t done that yet, follow my guide to set up an SPFx development environment with Heft first. Older posts and projects used gulp serve; since SPFx 1.22 the command is heft start, and you can migrate a gulp project to Heft.
1. Create the project
Open a terminal (I use the integrated terminal in VS Code) and run the generator:
md spg-app-customizer
cd spg-app-customizer
yo @microsoft/sharepoint
- What is your solution name? spg-app-customizer
- Which type of client-side component to create? Extension
- Which type of client-side extension to create? Application Customizer
- What is your Application Customizer name? AnnouncementBar
If you pick a name you regret later, here’s how to change the solution name in SPFx.
Application customizers don’t ask for a framework, so you get a plain TypeScript class. Then install the packages (this takes a few minutes):
npm install
Open the folder with code .. The extension lives in src/extensions/announcementBar, and the manifest there holds the component id (a GUID) that you’ll see again in serve.json, elements.xml and the debug URL.

2. Define the properties
Anything you pass in ClientSideComponentProperties arrives as this.properties. Replace the template’s testMessage interface in src/extensions/announcementBar/AnnouncementBarApplicationCustomizer.ts with the four values the banner needs:
/** Values come from serve.json (debug), elements.xml (site) or the Tenant Wide Extensions list. */
export interface IAnnouncementBarApplicationCustomizerProperties {
message: string;
linkText?: string;
linkUrl?: string;
footerText?: string;
}
Admins can now change the text and link per site without a new build, because the values live in the registration, not in the code.
3. Render the Top and Bottom placeholders
Here’s the full extension class in src/extensions/announcementBar/AnnouncementBarApplicationCustomizer.ts. I replaced the generated Dialog.alert sample with the header and footer code:
import { Log } from '@microsoft/sp-core-library';
import {
BaseApplicationCustomizer,
PlaceholderContent,
PlaceholderName
} from '@microsoft/sp-application-base';
import * as strings from 'AnnouncementBarApplicationCustomizerStrings';
import styles from './AnnouncementBar.module.scss';
const LOG_SOURCE: string = 'AnnouncementBarApplicationCustomizer';
/** Values come from serve.json (debug), elements.xml (site) or the Tenant Wide Extensions list. */
export interface IAnnouncementBarApplicationCustomizerProperties {
message: string;
linkText?: string;
linkUrl?: string;
footerText?: string;
}
/** Office clocks shown in the footer (IANA time zone names). */
const OFFICES: { name: string; zone: string }[] = [
{ name: 'New York', zone: 'America/New_York' },
{ name: 'Chicago', zone: 'America/Chicago' },
{ name: 'Los Angeles', zone: 'America/Los_Angeles' }
];
export default class AnnouncementBarApplicationCustomizer
extends BaseApplicationCustomizer<IAnnouncementBarApplicationCustomizerProperties> {
private _topPlaceholder: PlaceholderContent | undefined;
private _bottomPlaceholder: PlaceholderContent | undefined;
private _clockTimer: number | undefined;
public onInit(): Promise<void> {
Log.info(LOG_SOURCE, `Initialized ${strings.Title}`);
// Placeholders can appear (or be recreated) after onInit, so render whenever they change.
this.context.placeholderProvider.changedEvent.add(this, this._renderPlaceholders);
// Modern pages navigate in place: onInit does not run again, but navigatedEvent fires.
this.context.application.navigatedEvent.add(this, this._onNavigated);
this._renderPlaceholders();
return Promise.resolve();
}
protected onDispose(): void {
this._stopClocks();
super.onDispose();
}
private _onNavigated(): void {
Log.info(LOG_SOURCE, `Navigated to ${this.context.pageContext.site.serverRequestPath}`);
this._renderPlaceholders();
this._updateFooterSite();
}
private _renderPlaceholders(): void {
const available: string = this.context.placeholderProvider.placeholderNames
.map((name) => PlaceholderName[name])
.join(', ');
Log.info(LOG_SOURCE, `Available placeholders: ${available}`);
// ---- Top: announcement bar ----
if (!this._topPlaceholder) {
this._topPlaceholder = this.context.placeholderProvider.tryCreateContent(
PlaceholderName.Top,
{ onDispose: () => { this._topPlaceholder = undefined; } }
);
// Never assume a placeholder exists (for example, some pages have no Top/Bottom).
if (!this._topPlaceholder) {
Log.warn(LOG_SOURCE, 'The Top placeholder was not found.');
} else {
this._topPlaceholder.domElement.appendChild(this._buildHeader());
}
}
// ---- Bottom: footer with office clocks ----
if (!this._bottomPlaceholder) {
this._bottomPlaceholder = this.context.placeholderProvider.tryCreateContent(
PlaceholderName.Bottom,
{ onDispose: () => { this._stopClocks(); this._bottomPlaceholder = undefined; } }
);
if (!this._bottomPlaceholder) {
Log.warn(LOG_SOURCE, 'The Bottom placeholder was not found.');
} else {
this._bottomPlaceholder.domElement.appendChild(this._buildFooter());
this._startClocks();
}
}
}
private _buildHeader(): HTMLElement {
const { message, linkText, linkUrl } = this.properties;
const firstName: string = this.context.pageContext.user.displayName.split(' ')[0];
const bar: HTMLDivElement = document.createElement('div');
bar.className = styles.top;
bar.setAttribute('role', 'region');
bar.setAttribute('aria-label', 'Site announcement');
const text: HTMLSpanElement = document.createElement('span');
text.className = styles.message;
// textContent (not innerHTML) so property values can't inject markup.
text.textContent = `Hi ${firstName}, ${message || strings.DefaultMessage}`;
bar.appendChild(text);
if (linkText && linkUrl) {
const link: HTMLAnchorElement = document.createElement('a');
link.className = styles.link;
link.href = linkUrl;
link.textContent = linkText;
bar.appendChild(link);
}
return bar;
}
private _buildFooter(): HTMLElement {
const footer: HTMLDivElement = document.createElement('div');
footer.className = styles.bottom;
const site: HTMLSpanElement = document.createElement('span');
site.className = styles.site;
footer.appendChild(site);
const clocks: HTMLSpanElement = document.createElement('span');
clocks.className = styles.clocks;
footer.appendChild(clocks);
this._updateFooterSite(footer);
return footer;
}
private _updateFooterSite(root?: HTMLElement): void {
const scope: HTMLElement | undefined = root || this._bottomPlaceholder?.domElement;
const site: Element | null | undefined = scope?.querySelector(`.${styles.site}`);
if (site) {
const footerText: string = this.properties.footerText || strings.DefaultFooter;
site.textContent = `${this.context.pageContext.web.title} | ${footerText}`;
}
}
private _startClocks(): void {
this._stopClocks();
const tick = (): void => {
const clocks: Element | null | undefined =
this._bottomPlaceholder?.domElement.querySelector(`.${styles.clocks}`);
if (!clocks) { return; }
const now: Date = new Date();
clocks.textContent = OFFICES.map((office) =>
`${office.name} ${now.toLocaleTimeString('en-US', { timeZone: office.zone, hour: 'numeric', minute: '2-digit' })}`
).join(' • ');
};
tick();
this._clockTimer = window.setInterval(tick, 30000);
}
private _stopClocks(): void {
if (this._clockTimer !== undefined) {
window.clearInterval(this._clockTimer);
this._clockTimer = undefined;
}
}
}
tryCreateContent() returns a PlaceholderContent whose domElement is yours to fill. I build the elements with textContent instead of innerHTML, so a message typed by an admin can’t inject markup. The greeting uses pageContext.user.displayName, so you don’t need a REST call for the current user.

4. Add the styles and strings
Create src/extensions/announcementBar/AnnouncementBar.module.scss. The theme tokens pick up the site’s theme colors, so the bar matches every site it runs on:
// Theme tokens pick up the site's theme colors at runtime, with a default for local builds.
.top {
display: flex;
align-items: center;
justify-content: flex-start;
flex-wrap: wrap;
gap: 12px;
min-height: 40px;
padding: 8px 24px;
background-color: "[theme:themePrimary, default:#0078d4]";
color: "[theme:white, default:#ffffff]";
font-size: 14px;
font-weight: 600;
}
.message {
text-align: left;
}
.link {
color: "[theme:white, default:#ffffff]";
text-decoration: underline;
font-weight: 600;
&:hover,
&:focus {
color: "[theme:white, default:#ffffff]";
text-decoration: none;
}
}
.bottom {
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
gap: 8px;
min-height: 36px;
padding: 6px 16px;
background-color: "[theme:neutralLighter, default:#f3f2f1]";
color: "[theme:neutralPrimary, default:#323130]";
border-top-width: 1px;
border-top-style: solid;
border-top-color: "[theme:neutralLight, default:#edebe9]";
font-size: 13px;
}
.site {
font-weight: 600;
}
.clocks {
white-space: pre;
}
SPFx turns the class names into unique ones at build time, which is why the code uses styles.top rather than a plain "top" string. If you need the theme in code as well, see how to get the current theme in SPFx. Add the default texts to loc/en-us.js and loc/myStrings.d.ts:
define([], function() {
return {
"Title": "AnnouncementBarApplicationCustomizer",
"DefaultMessage": "welcome to the SPGuides intranet.",
"DefaultFooter": "SPGuides internal site"
}
});
declare interface IAnnouncementBarApplicationCustomizerStrings {
Title: string;
DefaultMessage: string;
DefaultFooter: string;
}
declare module 'AnnouncementBarApplicationCustomizerStrings' {
const strings: IAnnouncementBarApplicationCustomizerStrings;
export = strings;
}
Handle missing placeholders and page navigation
Most broken application customizers I’m asked to fix fail for one of three reasons. All three are handled in the class above:
- The placeholder isn’t there yet. Placeholders can show up after
onInit()runs, and some pages (for example, a list in a dialog or a full-screen app) don’t have them at all. Subscribe toplaceholderProvider.changedEvent, check the result oftryCreateContent(), and log a warning instead of throwing. - In-place navigation. Modern SharePoint moves between pages of the same site without a full reload, so
onInit()doesn’t run again.this.context.application.navigatedEventfires after the page context changes; I re-render there and refresh the site name in the footer. - Leaking timers. The
onDisposecallback of the Bottom placeholder (and the class’s ownonDispose()) clears the clock interval and resets the field, so the next render creates a fresh footer instead of writing into a removed element.
Don’t put logic in the constructor: this.context and this.properties are still undefined there. If you’re new to the component life cycle, my post on building your first SPFx web part explains onInit() in more detail.
Test with heft start and the debug query string
Web parts can be tested in the SharePoint workbench, but the workbench (including the site workbench at /_layouts/workbench.aspx) doesn’t load extensions, and the hosted workbench retires on 12/01/2026. So you test on a real modern page.
Set pageUrl in config/serve.json to a page on your site (mine is a Company News page on /sites/SPGuides) and put your properties under customActions, keyed by the manifest id:
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/spfx-serve.schema.json",
"port": 4321,
"https": true,
"serveConfigurations": {
"default": {
"pageUrl": "https://{tenantDomain}/sites/SPGuides/SitePages/SPGDemo-app-customizer.aspx",
"customActions": {
"a936356a-6474-42fc-a466-72a0f02a5b01": {
"location": "ClientSideExtension.ApplicationCustomizer",
"properties": {
"message": "Open enrollment for 2026 benefits closes on 11/14/2026.",
"linkText": "Review your benefits",
"linkUrl": "/sites/SPGuides/SitePages/SPGDemo-app-customizer-benefits.aspx",
"footerText": "Questions? Contact the IT Help Desk"
}
}
}
},
"announcementBar": {
"pageUrl": "https://{tenantDomain}/sites/SPGuides/SitePages/SPGDemo-app-customizer.aspx",
"customActions": {
"a936356a-6474-42fc-a466-72a0f02a5b01": {
"location": "ClientSideExtension.ApplicationCustomizer",
"properties": {
"message": "Open enrollment for 2026 benefits closes on 11/14/2026.",
"linkText": "Review your benefits",
"linkUrl": "/sites/SPGuides/SitePages/SPGDemo-app-customizer-benefits.aspx",
"footerText": "Questions? Contact the IT Help Desk"
}
}
}
}
}
}
Now start the local server. I add --nobrowser because I open the page in the browser where I’m already signed in; plain heft start opens your default browser for you:
heft start --nobrowser
Heft compiles the code, serves it from https://localhost:4321 and prints the debug query string to add to your pageUrl. Decoded, the full URL looks like this (in the terminal the properties are URL-encoded):

https://{tenantDomain}/sites/SPGuides/SitePages/SPGDemo-app-customizer.aspx?debugManifestsFile=https://localhost:4321/temp/build/manifests.js&noredir=true&loadSPFX=true&customActions={"a936356a-6474-42fc-a466-72a0f02a5b01":{"location":"ClientSideExtension.ApplicationCustomizer","properties":{"message":"Open enrollment for 2026 benefits closes on 11/14/2026."}}}
debugManifestsFile tells SharePoint to load your local manifest (Heft also adds noredir=true), loadSPFX=true makes sure the framework loads, and customActions registers the extension for this debug session only. SharePoint then asks for permission; select Load debug scripts.

The bar appears at the top of the page, above the site header, with my first name, the enrollment message and the link. It picks up the site’s theme color (red on this site). Nothing is installed; without the debug session the page is back to normal.

At the bottom of the page, the Bottom placeholder shows the site name and help desk text on the left and the three office clocks on the right:

To test navigation, I selected the bar’s link to the 2026 Benefits Enrollment page. SharePoint switched pages in place (a marker variable I set in the console survived, so there was no full reload), and the header and footer were still there:

Example: show office time zones in the header or footer
A popular variation of this example is a strip of clocks for each office, so people in New York can see whether it’s still working hours in Los Angeles.
You don’t need a library for it. toLocaleTimeString() with a timeZone option converts the time, and the browser handles daylight saving time. In the class above, that’s the OFFICES array plus _startClocks() and _stopClocks().
The clocks update every 30 seconds, which is plenty for an hour-and-minute display. To show them in the header instead, append the clocks element in _buildHeader(). Keep the interval handling as it is, because a timer that’s never cleared keeps running after the placeholder is gone.
Package the solution with npm run build
Stop heft start with Ctrl+C, then build the production package:
npm run build
The script runs heft test --clean --production and then heft package-solution --production. With includeClientSideAssets set to true (the default), the JavaScript is inside the package, so you don’t need a CDN. The result is sharepoint/solution/spg-app-customizer.sppkg.

The package also carries sharepoint/assets/elements.xml (registers the extension on a site when the app is added there) and ClientSideInstance.xml (used for tenant-wide deployment). Put your production property values in both files, because serve.json only affects debugging. When you’re ready, upload the .sppkg to the app catalog; The FAQ below links Microsoft’s guide to the site and tenant-wide options.
Other SPFx extension types
Application customizers are one of five extension types. If your requirement is about one list instead of every page, one of the others fits better:
| Extension type | What it changes | Guide |
|---|---|---|
| Field customizer | How a column’s values render in list views | SPFx field customizer example |
| ListView command set | Buttons in the list command bar and context menu | ListView command set tutorial |
| Command set (real use) | Replacing a built-in command bar button | customize the list Download button |
| Form customizer | The new, edit and display forms of a list | Fluent UI dropdown in a form customizer |
| Search query modifier | Search queries before they run | Covered on Microsoft Learn |
Two related fixes come up a lot: how to restrict a command set to one list or library, and the Sorry, something went wrong error in a form customizer.
Common errors and how to fix them
- Nothing shows, no error: the GUID in serve.json, elements.xml or the Tenant Wide Extensions item doesn’t match the
idin the manifest. Copy it from the manifest file. - The debug dialog never appears: the page URL in serve.json isn’t a modern page, or
heft startisn’t running. Open https://localhost:4321/temp/build/manifests.js in the same browser to check the server. - Header only on the first page: you render once in
onInit(). UsechangedEventandnavigatedEventas shown above. - Build errors after copying an older sample: its
@microsoft/sp-*packages must all be on the same SPFx version. See how to update the SPFx version. - Changes don’t show after deployment: you edited serve.json, which only affects debugging. Update elements.xml or the Tenant Wide Extensions item, bump the version in package-solution.json, rebuild and upload again.
Want a ready-made SharePoint Framework solution instead of building it from scratch? Browse our Power Platform and SPFx solutions page.
If you’re building more SPFx customizations, these guides cover the next steps:
Frequently Asked Questions
What is the difference between an application customizer and a web part?
A web part is added to one page by an editor and renders inside a page section. An application customizer is registered for a site, list or the whole tenant and runs on every modern page there, rendering into the Top and Bottom placeholders.
Can I use React in an SPFx application customizer?
Yes. Install react and react-dom at the versions your SPFx release supports (React 17.0.1 for SPFx 1.23), then call ReactDom.render() into the placeholder’s domElement and ReactDom.unmountComponentAtNode() in the onDispose callback. For a simple bar, plain DOM code like this example is enough.
Why does my application customizer disappear when I navigate to another page?
Modern SharePoint navigates in place, so onInit() runs only once. Render from placeholderProvider.changedEvent and application.navigatedEvent, and recreate the placeholder content when its onDispose callback has run.
How do I deploy an SPFx application customizer?
Upload the .sppkg from npm run build to the tenant app catalog. Then either add the app to a site, which activates the elements.xml custom action there, or deploy it to all sites through the Tenant Wide Extensions list. Microsoft covers both in deploy your extension to SharePoint.
Do I still use gulp serve to test an application customizer?
Not with SPFx 1.22 or later. Run heft start (or npm run start), open the page with the debug query string and select Load debug scripts. Older gulp-based projects can be migrated to Heft.

Hey! I’m Bijay Kumar, founder of SPGuides.com and a Microsoft Business Applications MVP (Power Automate, Power Apps). I launched this site in 2020 because I truly enjoy working with SharePoint, Power Platform, and SharePoint Framework (SPFx), and wanted to share that passion through step-by-step tutorials, guides, and training videos. My mission is to help you learn these technologies so you can utilize SharePoint, enhance productivity, and potentially build business solutions along the way.
Hi Thank you for the in detail explanation … It was really helpfull. My only doubt is that will application customizer works on only site pages or also on application pages too.