This example shows the basic usage of the AsyncLink component. When you click on the link, the onTrigger prop callback can return either true, false, or a promise. In this example, it shows the assigned message, "Wait...", and after two seconds this message disappears and shows the text "Submitted".
The AsyncLink component provides a way to navigate to a new page or route, but only after completing certain tasks or checks first. You can use it to control when and if the user is redirected based on specific conditions or operations.
Immediate navigation. If immediate navigation is needed without any preconditions or checks, avoid using the async link. Instead, use the link component.
Simple navigation. If the navigation doesn't involve any asynchronous tasks, such as data loading or user actions, using an async link might introduce unnecessary complexity. Instead, use the link component.
AsyncLink displays a loading indicator while fetching content. It consists of 3 pulsating dots. The loading indicator ensures that users are aware of ongoing activity.
AsyncLink handles errors by presenting an error message or fallback UI when necessary. Upon successful completion, it updates to display the fetched content.
The contrast ratio of textual elements against their background is above 4.5:1 as per WCAG 2.1 AA requirements. Non-textual content that needs to convey meaning (such as icons and keyboard focus visibility) has a contrast ratio of at least 3:1 with its adjacent colors. All content is visible and functional up to and including 400% without requiring scrolling in two dimensions.
This component has been validated to meet the WCAG 2.1 AA accessibility guidelines. However, changes made by the content author can affect accessibility conformance.
Follow the guidance below when using this component in your applications:
Ensure that any color changes meet the required threshold of 4.5:1.
Ensure screen readers convey the loading state and any error messages.
Avoid using words and phrases such as “Click here” or “here” as link text. Instead, create meaningful link text that makes sense on its own.
Make sure to understand the Design System components API surface, and the implications and trade-offs. Learn more in our introduction to the component API.
A new opt-in feature was introduced that disables automatic event publishing for the AsyncLink component. You can enable this feature by adding JUTRO_DISABLE_AUTO_EVENTS_PUBLISHING=true to the .env file in the root of your Jutro application. When this is enabled, legacy components no longer publish events by default. For more information on events and how to set up new events, see the Events documentation.