API Reference

Components

AppClientProvider

The root provider component that enables communication with the shell application.

import { AppClientProvider } from '@akinon/app-client';

Props

Property
Type
Required
Default
Description

children

ReactNode

Yes

-

Child components

config

FullpageApplicationConfig | PluginApplicationConfig

Yes

-

Application configuration

eventBus

Framebus

No

undefined

Custom framebus instance (for testing)

Usage

<AppClientProvider config={{ isDev: true }}>
  <App />
</AppClientProvider>

MultiAppProvider

Enables multiple client applications to be served from a single URL with different base paths.

import { MultiAppProvider } from '@akinon/app-client';

Props

Property
Type
Required
Description

children

ReactNode

Yes

Child components

multiConfig

MultiAppConfig

Yes

Configuration for multiple apps

Usage


Hooks

useAppClient

Access the client context for communicating with the shell.

Return Value: AppClientContextState

Property
Type
Description

data

ApplicationData | undefined

Shared data from shell

params

ApplicationParams | undefined

Plugin parameters

isLoading

boolean

Data loading state

modalContext

unknown

Rich modal context data

locale

string

Current locale

navigate

(payload: ShellNavigationPayload) => void

Request shell navigation

invokeAction

<T>(key: string, ...args: unknown[]) => Promise<T>

Invoke custom action

showModalDialog

(options: ModalDialogOptions) => boolean

Show modal dialog

showConfirmationDialog

(options: ConfirmDialogOptions) => boolean

Show confirmation

showToast

(content: string, type: ToastType) => boolean

Show toast

showErrorMessage

(title: string, content: string) => boolean

Show error

showRichModal

(path, context?, size?, closeIconColor?) => boolean

Show rich modal

removeSearchParams

(keys: string | string[]) => void

Remove URL params

setSearchParams

(params: Record<string, string | number>) => void

Set URL params

onLocaleChange

(callback: (locale: string) => void) => () => void

Subscribe to locale changes


Types

AppClientContextState

The context state provided by AppClientProvider.


FullpageApplicationConfig

Configuration for fullpage applications.


PluginApplicationConfig

Configuration for plugin applications.


ApplicationConfig

Base configuration interface.


ShellNavigationPayload

Payload for navigation requests.


ApplicationData

Shared data from the shell.


ApplicationParams

Parameters for plugin applications.


ApplicationModalSize

Modal size configuration.


MultiAppConfig

Configuration for multiple applications.


Events

AppClient listens for and emits the following events:

Event
Direction
Description

SET_CONFIG

Client → Shell

Client sends its configuration

SET_DATA

Shell → Client

Shell sends shared data

SET_APP_ID

Shell → Client

Shell sends app identifier

SET_MODAL_CONTEXT

Shell → Client

Shell sends modal context

SET_PARAMS

Shell → Client

Shell sends plugin parameters

INVOKE_ACTION

Client → Shell

Client invokes custom action

INVOKE_DEFAULT_ACTION

Client → Shell

Client invokes default action

NAVIGATE

Client → Shell

Client requests navigation

NAVIGATE_CHILD

Shell → Client

Shell triggers client navigation

ACTION_CONFIRMED

Shell → Client

Shell confirms an action

ACTION_CANCELED

Shell → Client

Shell cancels an action

LOCALE_CHANGED

Shell → Client

Shell notifies locale change

SET_HEIGHT

Client → Shell

Client sends iframe height

Notes

circle-exclamation
  • Introduction - Getting started with AppClient

  • Hooks - Using the useAppClient hook

  • Configuration - Application configuration

Last updated

Was this helpful?