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.
Non-textual content that needs to convey meaning (like icons and focus indicators) has a contrast ratio of at least 3:1 with its adjacent colors.
The item is operable using a keyboard, as well as using a mouse.
Content is accessible using screen readers, such as JAWS and VoiceOver.
Accessibility conformance ultimately depends on how this component is implemented and customized. Changes made by the content author can affect accessibility. For details on our shared responsibility model, please review our full Jutro accessibility statement.
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.
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".
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.