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:
- Static
- Dynamic
const MyStack = createNativeStackNavigator({
screens: {
Home: createNativeStackScreen({
screen: HomeScreen,
options: {
title: 'My home',
},
}),
},
});
const Stack = createNativeStackNavigator();
function MyStack() {
return (
<Stack.Navigator>
<Stack.Screen
name="Home"
component={HomeScreen}
options={{
title: 'My home',
}}
/>
</Stack.Navigator>
);
}

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:
- Static
- Dynamic
const MyStack = createNativeStackNavigator({
screens: {
Home: createNativeStackScreen({
screen: HomeScreen,
options: {
title: 'My home',
},
}),
Profile: createNativeStackScreen({
screen: ProfileScreen,
options: ({ route }) => ({
title: route.params.name,
}),
}),
},
});
const Stack = createNativeStackNavigator();
function MyStack() {
return (
<Stack.Navigator>
<Stack.Screen
name="Home"
component={HomeScreen}
options={{
title: 'My home',
}}
/>