useAppShell

The primary hook for accessing the shell context. It provides access to registered apps, configurations, navigation, and iframe references.

import { useAppShell } from '@akinon/app-shell';

const ShellComponent = () => {
  const { apps, configs, navigate } = useAppShell();

  return (
    <div>
      <h1>Registered Apps: {apps.length}</h1>
      <button onClick={() => navigate({ path: '/dashboard' })}>
        Go to Dashboard
      </button>
    </div>
  );
};

Return Value

The useAppShell hook returns an AppShellContextState object:

Property
Type
Description

apps

RegisteredApp[]

List of registered micro-frontend applications

configs

Map<number | UUID, ApplicationConfig>

Configuration for each registered app

navigate

(payload: NavigationPayload) => void

Navigation function

frames

MutableRefObject<Map<number | UUID, HTMLIFrameElement>>

References to iframe elements

buses

MutableRefObject<Map<number | UUID, Framebus>>

Framebus instances for communication

instances

Map<number | UUID, AppInstanceInfo>

App instances by ID

modals

Map<UUID, number | UUID>

UUID values for rich modals

modalContext

Map<UUID, unknown>

Context data for modals

AppShellContextState Type

Usage Examples

Accessing Registered Apps

Programmatic Navigation

Accessing App Configurations

Working with Iframe References

Sending Messages via Framebus

Best Practices

1. Use at the Right Level

Call useAppShell in components that need shell context, not at the top level:

2. Check for Optional Values

Some properties are optional and may be undefined:

3. Memoize Derived Values

When computing values from the context, memoize them:

Last updated

Was this helpful?