Async steps

Async steps allow tours to wait for user actions or external events before proceeding. Unlike regular steps that users can navigate immediately, async steps require something to happen first - like submitting a form, clicking a specific button, or waiting for data to load.

How It Works

Async steps have three states:

  1. Pending - Waiting for the user to start an action

  2. Processing - The action is in progress

  3. Success - The action is complete, can now continue

Basic Example

const tour: TourConfig = {
  id: 'form-tour',
  steps: [
    {
      id: 'fill-form',
      type: 'async',
      page: '/signup',
      content: {
        pending: {
          targetElement: '#email-input',
          title: 'Enter Your Email',
          content: 'Type your email address and click Submit',
        },
        processing: {
          targetElement: '#submit-button',
          title: 'Processing...',
          content: 'Validating your email',
        },
        success: {
          targetElement: '#success-message',
          title: 'Email Verified!',
          content: 'Great! Now you can continue',
        },
      },
    },
  ],
};

Controlling Async Steps

The easiest way to control async steps is using tour helpers, which provide the correct event names automatically:

Manual Event Names

Alternatively, you can send events directly, the library is completely typed and should provide you with the correct event names.

Custom Event Names

You can customize the event names for better readability:

Common Use Cases

Waiting for Button Click

Form Submission

Data Loading

  • During pending: Users can go back (if canPrev isn't false)

  • During processing: Navigation is typically disabled

  • During success: Users can continue to the next step

Default Event Names

If you don't specify custom event names, Tourista generates them based on the step ID:

  • Start: START_[STEP_ID] (e.g., START_LOGIN)

  • Success: [STEP_ID]_SUCCESS (e.g., LOGIN_SUCCESS)

  • Failed: [STEP_ID]_FAILED (e.g., LOGIN_FAILED)

Complete Example

Best Practices

  1. Clear instructions: Tell users exactly what action to take

  2. Show progress: Use the processing state to show something is happening

  3. Handle failures: Always implement the failed event to handle errors gracefully

  4. Keep it simple: Don't overuse async steps - only when you really need to wait for user actions

Last updated