npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ptech-shell-react

v2.6.0-rc.3

Published

Production React adapters (MSAL bootstrap, auth gate, user service, react-router navigation) for Module Federation shell apps.

Downloads

1,053

Readme

ptech-shell-react

Production React adapters for PTECH Module Federation shell apps.

This package bridges framework/runtime libraries into the contracts exported by ptech-shell-sdk.

Exports

Root entry:

import {
  createMsalUserService,
  createReactRouterNavigationAdapter,
} from 'ptech-shell-react';

The root entry stays react-router runtime-free. It exports:

  • createMsalUserService
  • createReactRouterNavigationAdapter
  • related MSAL and navigation adapter types

React Router subpath:

import {
  ShellRouterBridge,
  ShellRouterProvider,
  detectBasenameFromKnownRoots,
} from 'ptech-shell-react/react-router';

Import this subpath only in code that has React Router available.

MSAL bootstrap subpath:

import {
  createMsalInstance,
  createMsalRedirectHooks,
  planInteractiveAuthRedirect,
} from 'ptech-shell-react/msal';

Import ./msal when bootstrapping MSAL at app startup (no React required).

MSAL React subpath:

import { MsalAuthGate, useAuth } from 'ptech-shell-react/msal-react';

Import ./msal-react only under <MsalProvider>.

MSAL User Service

Use createMsalUserService in production hosts that authenticate through MSAL.

import { registerService, TOKENS } from 'ptech-shell-sdk';
import { createMsalUserService } from 'ptech-shell-react';
import { createMsalRedirectHooks } from 'ptech-shell-react/msal';

registerService(
  TOKENS.userService,
  createMsalUserService({
    msal,
    defaultScopes: ['api://example/access_as_user'],
    loginMode: 'redirect',
    logoutMode: 'redirect',
    tokenInteractionMode: 'redirect',
    ...createMsalRedirectHooks({ redirectAttemptCap: 2 }),
  }),
);

MSAL Bootstrap and Auth Gate

Use createMsalInstance once at startup, wrap the app with MsalProvider, then gate rendering with MsalAuthGate:

import { MsalProvider } from '@azure/msal-react';
import { createMsalInstance } from 'ptech-shell-react/msal';
import { MsalAuthGate } from 'ptech-shell-react/msal-react';

const msal = await createMsalInstance(msalConfig);

<MsalProvider instance={msal}>
  <MsalAuthGate requireAccessToken tokenScopes={['api://example/access_as_user']}>
    <App />
  </MsalAuthGate>
</MsalProvider>

For direct MSAL hook usage (outside the shell UserService contract), use useAuth from ptech-shell-react/msal-react.

The adapter implements the SDK UserService contract:

  • getSnapshot
  • getSession
  • acquireAccessToken
  • login
  • logout
  • subscribe

Host-specific claim mapping belongs in mapUser; keep product-specific mapping out of this package.

React Router Navigation

Use createReactRouterNavigationAdapter when wiring React Router to the SDK NavigationService contract directly.

import { registerService, TOKENS } from 'ptech-shell-sdk';
import { createReactRouterNavigationAdapter } from 'ptech-shell-react';

const adapter = createReactRouterNavigationAdapter({ basename: '/audit-tool' });
registerService(TOKENS.navigation, adapter.service);

App-Owned Router

Use ShellRouterProvider when the app owns its top-level router.

import { ShellRouterProvider } from 'ptech-shell-react/react-router';

export function AppRoot() {
  return (
    <ShellRouterProvider basename="/audit-tool">
      <AppRoutes />
    </ShellRouterProvider>
  );
}

ShellRouterProvider creates/registers the navigation adapter and renders a BrowserRouter.

Host-Owned Router

Use ShellRouterBridge when a remote is mounted inside a router owned by the host. Do not nest another router in this topology.

import { registerService, TOKENS } from 'ptech-shell-sdk';
import { createReactRouterNavigationAdapter } from 'ptech-shell-react';
import { ShellRouterBridge } from 'ptech-shell-react/react-router';

const adapter = createReactRouterNavigationAdapter({ basename: '/t/demo/audit-tool' });
registerService(TOKENS.navigation, adapter.service);

export function RemoteRoot() {
  return (
    <>
      <ShellRouterBridge adapter={adapter} basename="/t/demo/audit-tool" />
      <RemoteRoutes />
    </>
  );
}

Basename Detection

Prefer an explicit basename. detectBasenameFromKnownRoots is a fallback for older remotes that need to infer a host mount prefix from the current path.

import { detectBasenameFromKnownRoots } from 'ptech-shell-react/react-router';

const basename = detectBasenameFromKnownRoots(window.location.pathname, [
  'audit-tool',
  'settings',
]);

Build

npm run build -w ptech-shell-react

The build has four entries:

  • .: MSAL user service and navigation adapter, without importing React Router or MSAL React.
  • ./react-router: React Router components and helpers.
  • ./msal: MSAL bootstrap utilities (createMsalInstance, redirect loop breaker).
  • ./msal-react: MsalAuthGate and useAuth (requires @azure/msal-react).