Different image in layout based on route?
Answered
Red-necked Grebe posted this in #help-forum

Red-necked GrebeOP
I have a layout for a login & signup page but I want different images based on the route you're on. Is there a way to do that with layouts? Or do I just have to copy-paste the actual html layout code to a login & signup page and change the image that way?
3 Replies

Havana
You could determine it based on the pathname which you can get from importing „usePathname“ from „next/navigation“ and then using it like this:
const pathname = usePathname()
. Based on the pathname you could determine if the user is on the login or signup page and change the image accordingly
@Havana You could determine it based on the pathname which you can get from importing „usePathname“ from „next/navigation“ and then using it like this: const pathname = usePathname(). Based on the pathname you could determine if the user is on the login or signup page and change the image accordingly

Red-necked GrebeOP
thanks, that worked nicely
Answer

@Red-necked Grebe thanks, that worked nicely

Large garden bumble bee
Please mark the solution