Skip to main content
Version: 8.x

Configuring the header bar

We've seen how to configure the header title already, but let's go over that again before moving on to some other options.

Setting the header title

Each screen has an options property (an object or function returning an object) for configuring the navigator. For the header title, we can use the title option:

const MyStack = createNativeStackNavigator({
screens: {
Home: createNativeStackScreen({
screen: HomeScreen,
options: {
title: 'My home',
},
}),
},
});

Header title

Using params in the title

To use params in the title, make options a function that returns a configuration object. React Navigation calls this function with { navigation, route } - so you can use route.params to access the params:

const MyStack = createNativeStackNavigator({
screens: {
Home: createNativeStackScreen({
screen: HomeScreen,
options: {
title: 'My home',
},
}),
Profile: createNativeStackScreen({
screen: ProfileScreen,
options: ({ route }) => ({
title: route.params.name,
}),
}),
},
});