Skip to main content

<RedirectToTasks />

The <RedirectToTasks /> component will navigate to the tasks flow which has been configured in your application instance when users have pending . The behavior will be just like a server-side (3xx) redirect, and will override the current location in the history stack.

The prebuilt session task flow is hosted through Clerk's Account Portal. For example, if the user has a pending choose-organization task, they will be redirected to the /tasks/choose-organization Account Portal page. If you don't want to use the prebuilt components or Account Portal, you can build a custom flow.

Example

Your sign-up/sign-in flow should handle session tasks, but if a user's authentication flow is interrupted and they aren't able to complete the tasks, you can use the <RedirectToTasks /> component to redirect them to the appropriate task page.

With the default hash routing used by <SignIn /> in Expo web, the <RedirectToTasks /> component redirects to the /sign-in#/tasks/<task-key> URL, expecting the <SignIn /> component to be hosted on the /sign-in route. If it is, then the <SignIn /> component will handle the session task flows. However, if you want to customize the paths where specific tasks are redirected, you can use the taskUrls option on <ClerkProvider>.

Note

The <RedirectToTasks /> component is only available in Expo web projects. It is not supported in native iOS and Android apps.

In the following example, the <RedirectToTasks /> component is rendered from a web-specific layout so that users can't access any page in the route group until they complete their pending session tasks. Expo Router requires a non-platform layout alongside a platform-specific layout, so this example includes both files.

src/
└── app/
    └── (protected)/
        ├── _layout.tsx
        └── _layout.web.tsx
src/app/(protected)/_layout.tsx
import { Slot } from 'expo-router'

export default function Layout() {
  return <Slot />
}
src/app/(protected)/_layout.web.tsx
import { RedirectToTasks } from '@clerk/expo/web'
import { Slot } from 'expo-router'

export default function Layout() {
  return (
    <>
      <RedirectToTasks />
      <Slot />
    </>
  )
}

Feedback

What did you think of this content?

Last updated on