Actions
The AppShell library enables seamless interaction between the shell and its micro-frontends through a robust action system.
Overview
Actions are mechanisms through which clients can request the shell to perform certain operations, such as displaying messages, navigating between pages, or invoking custom logic.
Action Types
AppShell supports two types of actions:
Default Actions - Predefined UI operations (toast, modal, confirmation dialog)
Custom Actions - Application-specific operations defined by the shell
Default Actions
Default actions are predefined operations that ensure a consistent user experience across micro-frontends. These actions cover common functionalities that clients frequently need.
Available Default Actions
showModalDialog
(title, content)
Display a modal dialog with title and content
showConfirmationDialog
(title, content)
Show a confirmation dialog, returns boolean
showToast
(content, type)
Show a brief toast notification
showErrorMessage
(title, content)
Display an error message prominently
showRichModal
(uuid, path, context?, size?, closeIconColor?)
Open a rich modal with iframe content
removeSearchParams
(keys)
Remove specified URL search parameters
setSearchParams
(searchParams)
Set or update URL search parameters
Implementing Default Actions
Custom Actions
Beyond default actions, you can define custom actions specific to your application. These are operations that micro-frontends can invoke to interact with the shell.
Defining Custom Actions
Combining Actions
Pass both default and custom actions to AppShellProvider:
ApplicationActions Type
Invoking Actions (Client Side)
Clients invoke actions via the useAppClient hook:
Async Actions
Actions can be asynchronous. The client will await the result:
Best Practices
1. Keep Actions Simple
Actions should perform a single, well-defined operation.
2. Return Values When Needed
If clients need a result, make sure to return it:
3. Handle Errors Gracefully
Catch and handle errors within actions:
Next Steps
Navigation - Configure navigation helpers
Data Sharing - Share data with clients
Last updated
Was this helpful?

