If you're using expo-router's Stack Navigator (version 51+ to be precise) then you can refer this page of official docs to configure the header bar dynamically for an individual route.
Example
My app folder's structure is like this
app
- _layout.tsx
- index.tsx // renders Customer.tsx
- customer_details.tsx // renders CustomerDetails.tsx
In _layout.tsx I use Stack Navigator like this.
import {Stack} from 'expo-router'
const RootLayout = () => {
return <Stack/>
}
The index.tsx file looks like this
Customer.tsx -> which is one of the routes
<Link
style={[styles.card, { backgroundColor: theme.colors.inputBackground }]}
asChild
href={{
pathname: "/(app)/customer_details",
params: { customerName: item.name },
}}
>
<Pressable>
.........
When I press the link, it renders the below customer_details.tsx screen which is CustomerDetails.tsx component like this where I am able to dynamically render the customerName in this screen's header title which I had defined in my Customer.tsx screen above
const CustomerDetails = () => {
const { customerName } = useLocalSearchParams();
return (
<View>
<Stack.Screen
options={{
headerTitle: customerName ? (customerName as string) : "Transactions",
}}
/>
<Text>CustomerDetails</Text>
</View>
);
};
export default CustomerDetails;
const styles = StyleSheet.create({});
Hope that helps!