Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ag.common/header

Package Overview
Dependencies
Maintainers
4
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ag.common/header

## Installation

  • 2.1.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-88.24%
Maintainers
4
Weekly downloads
 
Created
Source

Header

Installation

yarn add @ag.common/header

Usage

import { Header } from '@ag.common/header';

function App() {
	return (
		<>
			<Header activePath="/" authenticated={false} handleSignIn={console.log} />
			<YourApplication />
		</>
	);
}

By default, this component renders the main navigation element with the ID of main-nav. This can be overridden using the mainNavId prop.

We encourage this component to be paired with the SkipLinks component available from the @ag.ds-next/skip-link package.

import { Header } from '@ag.common/header';
import { SkipLinks } from '@ag.ds-next/react/skip-link';

function App() {
	return (
		<>
			<SkipLinks
				links={[
					{ href: '#main-content', label: 'Skip to main content' },
					{ href: '#main-nav', label: 'Skip to main navigation' },
				]}
			/>
			<Header />
			<YourApplication id="main-content" />
		</>
	);
}

Usage with MSAL client library

import { Fragment, useState } from 'react';
import { useRouter } from 'next/router';
import { Header } from '@ag.common/header';
import { useMsal, useIsAuthenticated } from '@azure/msal-react';

function App() {
	const router = useRouter();
	const { instance } = useMsal();
	const authenticated = useIsAuthenticated();
	const [isAuthenticating, setIsAuthenticating] = useState(false);
	const SCOPE = '...';

	const handleSignIn = async () => {
		setIsAuthenticating(true);
		await instance.loginRedirect({
			scopes: [SCOPE],
			prompt: 'login',
		});
		setIsAuthenticating(false);
	};

	return (
		<Fragment>
			<Header
				activePath={router.asPath}
				authenticated={authenticated}
				handleSignIn={handleSignIn}
			/>
			{isAuthenticating && (
				<LoadingBlanket
					fullScreen
					label="You are being redirected to myGovID"
				/>
			)}
			<YourApplication />
		</Fragment>
	);
}

FAQs

Package last updated on 06 Feb 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc