Actions

Client applications can invoke actions defined in the shell application.

This allows micro-frontends to trigger shell functionality such as showing toasts, opening modals, or calling custom business logic.

Action Types

There are two types of actions:

  1. Default Actions - Built-in UI actions (toast, modal, confirmation)

  2. Custom Actions - Application-specific actions defined by the shell

Using Default Actions

Default actions are available directly from useAppClient:

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

const MyComponent = () => {
  const { 
    showToast, 
    showModalDialog, 
    showConfirmationDialog,
    showErrorMessage,
    showRichModal 
  } = useAppClient();

  // Use these functions to invoke default actions
};

showToast

Display a brief notification message:

showConfirmationDialog

Display a confirmation dialog with callbacks:

showModalDialog

Display an informational modal:

showErrorMessage

Display an error message prominently:

showRichModal

Open a rich modal with micro-frontend content:

Using Custom Actions

Custom actions are invoked via invokeAction:

URL Search Params

Manage URL search parameters via shell actions:

Accessing Modal Context

When opened via showRichModal, access the context:

Best Practices

1. Error Handling

Always wrap action invocations in try-catch:

2. Loading States

Show loading indicators during async actions:

3. Type Safety

Type your action results:

Next Steps

  • Navigation - Client-side navigation

  • Hooks - Complete useAppClient reference

Last updated

Was this helpful?