
Security News
Next.js Patches Critical Middleware Vulnerability (CVE-2025-29927)
Next.js has patched a critical vulnerability (CVE-2025-29927) that allowed attackers to bypass middleware-based authorization checks in self-hosted apps.
@financial-times/dotcom-ui-header
Advanced tools
This package provides templates which render variants of the FT.com header and navigation.
This package provides templates which render variants of the FT.com header and navigation.
This package is compatible with Node 12+ and is distributed on npm.
npm install --save @financial-times/dotcom-ui-header
After installing the package you will need to configure your application to fetch data from the Next Navigation API required to render these UI components. Page Kit provides two packages for this:
dotcom-middleware-navigation
(if you are using Express)dotcom-server-navigation
(if you are not using Express)This package provides several UI components to render different parts and styles of the FT.com header:
<Header />
the full header with navigation with lots of options. See header elements for a breakdown of its parts.<Drawer />
the navigation drawer which should be rendered separately from the header, preferably near the bottom of the document.<LogoOnly />
a simple masthead displaying the logo image which doesn't require any configuration. Doesn't link to the homepage by default, pass in a showLogoLink={true}
prop to make it link through.<NoOutboundLinksHeader />
a stripped back masthead displaying the logo image, user actions and optional sub-navigation. Aimed at reducing the possibility of a user clicking through to content related pages.import { Header, Drawer } from '@financial-times/dotcom-ui-header'
const SiteHeader = (props) => (
<Header data={props.navigationData} userIsLoggedIn={props.userIsLoggedIn} />
<Drawer data={props.navigationData} userIsLoggedIn={props.userIsLoggedIn} userIsSubscribed={props.userIsSubscribed} />
)
Please note that the header components are designed to be used on the server-side and should not be rendered on the client-side. Although it is possible to render them on the client-side there is usually no reason to do so and is not supported.
Once you are rendering the header components in your page you will need to initialise the client-side code to add styles and interactive behaviour.
To initialise the client-side JavaScript import the package and call the .init()
method:
import * as header from '@financial-times/dotcom-ui-header'
header.init()
This component includes styles written in Sass which can be imported into your application's main Sass stylesheet.
@import '@financial-times/dotcom-ui-header/styles';
Please note that the exact usage of styles will depend on how you configure your Sass compiler and whether or not you are using Bower to install dependencies.
All header components with the exception of <LogoOnly />
require the following options:
OPTION | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
variant | 'simple' | 'large-logo' | string | true | 'simple' | Adds a class name to the header element |
userIsAnonymous | boolean | true | true | Marks a user as anonymous - can be set by middleware included with n-express |
userIsLoggedIn | boolean | true | false | Marks a user as logged in - can be set by middleware included with n-express |
userIsSubscribed | boolean | true | false | Marks a user as subscribed - set by middleware(ammit task in preflight) included with n-express |
showUserNavigation | boolean | true | true | Show user navigation options such as Sign out or Subscribe |
showSubNavigation | boolean | true | true | Show the sub-navigation component which may include the crumbtrail |
showStickyHeader | boolean | true | true | Enable rendering of the sticky header component |
showMegaNav | boolean | true | true | Enable rendering of the drop-down "mega-nav" |
showAskButton | boolean | true | false | Enable rendering of the ASK button |
data | object | false | Navigation data for rendering the header links fetched from the navigation API |
The topmost element - or masthead - contains the logo, toggle buttons for the drawer and search bar, and the MyFT indicator if logged in.
By default the logo serves as a home page link, which can be deactivated by providing prop showLogoLink: false
.
Please note that the myFT unread articles indicator code lives outside this package in n-myft-ui
.
The navigation element contains links for navigating the top-level sections of FT.com. Some of the sections may include subsections which are presented in "mega-nav" dropdown elements.
Please note that the data for this menu is regionally-specific and changes depending on the selected FT edition.
If enabled the sub-navigation element will be rendered if either crumbtrail or subsection navigation data is provided. This is usually page specific and will be automatically set when using thedotcom-middleware-navigation
package.
The drawer menu is a separate component and is not included within the header. It is the primary navigation on small screens and supplementary on large screens. It mostly re-uses the data from the navigation element but can also have extra groups of links.
To support a non-JS, or core experience, the drawer component should be rendered near the bottom of the document.
If enabled the sticky header is shown when users scroll down on both small and large screens. It combines similar components to the top and navigation elements.
These are SVG logos as React components, which can be imported for inclusion by other components.
Rendering logos as SVGs allows them to be visible faster than as external images, so is an approach best applied to logos that need to be displayed as quickly as possible upon visiting a page.
The React components are auto-generated using a script - npm run build:svg-to-react
- which converts the source SVG file acquired from dev dependency @financial-times/logo-images
.
FAQs
This package provides templates which render variants of the FT.com header and navigation.
The npm package @financial-times/dotcom-ui-header receives a total of 1,070 weekly downloads. As such, @financial-times/dotcom-ui-header popularity was classified as popular.
We found that @financial-times/dotcom-ui-header demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Next.js has patched a critical vulnerability (CVE-2025-29927) that allowed attackers to bypass middleware-based authorization checks in self-hosted apps.
Security News
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
Product
Socket, the leader in open source security, is now available on Google Cloud Marketplace for simplified procurement and enhanced protection against supply chain attacks.