#Is there a way to access the content of the page AFTER it is rendered

17 messages · Page 1 of 1 (latest)

novel forge
#

I want to modify the content of a page after next rendered it. However I still need to do it on server side and not on client side. Is there any way ?
I've looked into the middleware functions but middleware is only running BEFORE the rendering.
Thanks for ur help

green thornBOT
#

🔎 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)

ornate sequoia
novel forge
ornate sequoia
novel forge
#

no

#

this is why i am asking that

ornate sequoia
# novel forge this is why i am asking that

how would your page be able to generate it? The generateMetadata function get's exactly the same params, like your page. So if you page is able to generate it, generateMetadata should be too

novel forge
ornate sequoia
#

Maybe you can give us an example or even provide more details on what's the goal. This may help: https://xyproblem.info/

ornate sequoia
#

@novel forge are you able to provide more info?

novel forge
#

Hello 👋 yes thank you for helping me. You are right about my situation it indeed is a xyproblem. The thing is that the inital problem (x) is really complexe and long to explain.
To make it short :
I have a scss file that represent the entire style of my whole website. This stylesheet use some variable for the color ($color1, $color2, etc.) and those color are not in the style sheet. They are on a database and this everytime a request is made to get this stylesheet, the value of the colors are fetched on a database and the stylesheet is compiled with the fetched color to make a fully functional stylesheet.
To achieve this behavior I had to rewrite the default path of /*/style.css to an api route on next that return a stylesheet (it is this route where the color are fetched and the scss is compiled) . To make all my pages call this route I then had to add a <Script> tag on all my route to manually add the <link rel=“stylesheet” href=<my api route> /> to make them call that api route.
The result is that the content is loaded on the client. The script is executed, and the the stylesheet is fetched. So everything is working but there is a delay between the content loading and the style loading, resulting in a ugly page for few second before the style is loaded.
The Y solution I wanted to achieve (my original question) was to know if there was a way to “catch” the content of the page just before it is sent to the client, to add my <link rel=…> on it.
I don’t know if I am clear but is kinda a complex problem @ornate sequoia

prisma brook
#

i think you can simply just render the tag

function AnyComponent() {
  return (
    ...
    <link rel="stylesheet" precedence="high" href="..." />
  )
}
#

like, directly in the page, as a regular react component. it will be added to <head> and things will work normally

novel forge
#

I looked into the documentation and saw that the <Head> component available in next 13 was no longer available. Therefore I assumed that it was not possible to just head tags like this.
I am gonna try this solution and close the ticket if it works. Thank you very much