ArchiveExpo SnackDiscord and ForumsNewsletter


Edit this page

Learn how to redirect URLs in Expo Router.

You can redirect a request to a different URL based on some in-app criteria. Expo Router supports a number of different redirection patterns.

Using Redirect component

You can immediately redirect from a particular screen by using the Redirect component:

import { View, Text } from 'react-native';
import { Redirect } from 'expo-router';

export default function Page() {
  const { user } = useAuth();

  if (!user) {
    return <Redirect href="/login" />;

  return (
      <Text>Welcome Back!</Text>

Using useRouter hook

You can also redirect imperatively with the useRouter hook:

import { Text } from 'react-native';
import { useRouter, useFocusEffect } from 'expo-router';

function MyScreen() {
  const router = useRouter();

  useFocusEffect(() => {
    // Call the replace method to redirect to a new route without adding to the history.
    // We do this in a useFocusEffect to ensure the redirect happens every time the screen
    // is focused.

  return <Text>My Screen</Text>;