#Pass a variable to the Layout

5 messages · Page 1 of 1 (latest)

clear pilot
#

This might be an anti pattern but I'd like to pass a variable to my layout. I'd like to be able to set on each page.tsx a variable of backUrl or somesort, as in my layout I want to put a Back button for any page that has this variable

Can anyone make a suggestion to solve this problem please?

cursive canopyBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

hushed swift
#

if you want a layout that's different for each page, then I think what you want is a template, because a layout is supposed to be rendered once

#

or instead of deoptimizing the entire layout, make the back link component a client component that reads the current segment and shows a correct back link

clear pilot
#

Thanks for your response, if I was to use a template instead is there any way to get a value from the page to the template? For instance if I had /libraries/1/books/1/edit, and I wanted to add a Back button to take someone back to /libraries/1/books, how would I do that? It looks like the segment value only returns libraries for me