DEV Community

Andreas Bergström
Andreas Bergström

Posted on

How to set the initial route in Expo Router

Building a seamless and intuitive navigation system is a critical aspect of any mobile application. To facilitate this, developers often turn to robust solutions like React Navigation or Expo Navigation. Expo, a popular framework for building cross-platform applications using React Native, provides powerful tools for creating and managing navigation within an app. This article will discuss how to set the initial route in an Expo Route app using the initialRouteName property and provide a brief overview of Expo's navigation system.

Expo simplifies the development process by providing a comprehensive set of tools and services, enabling developers to build, deploy, and iterate on their applications more efficiently. One of the most significant aspects of any mobile application is its navigation system, which allows users to move seamlessly between different screens or sections. Expo Router is based on React Navigation and is a built-in solution that helps developers create and manage navigation within their applications.

To set the initial route in an Expo Route app, you can use the initialRouteName property on the Slot/Stack component. This property allows you to define which route the app should load when it is first opened. Here's a code snippet illustrating how to set the initial route:

return (
    <>
      <StatusBar barStyle="light-content" />
      <QueryClientProvider client={queryClient}>
        <Slot initialRouteName="/home" />
      </QueryClientProvider>
    </>
  )
Enter fullscreen mode Exit fullscreen mode

Top comments (0)