jolly-doctor-34097
10/02/2025, 7:13 AMtrackingCallback get called two times? First, when the server prerenders the page, and then on the client side?
2. How is the server supposed to set the attributes when it initialize the Growthbook instance inside the MyPage component? I mean, in the example you clearly show that you set the id property by reading it from the cookies (i.e., Cookies.get('my_uuid') ), but when the server prerenders the page doesn't have access to cookies, at least inside the render function. Doesn't this involve a mismatching attribution between client and server, causing hydration errors?
Thanks in advance 🙏strong-mouse-55694
10/02/2025, 2:54 PMtrackingCallback may fire twice, but GrowthBook automatically deduplicates these events.
2. With SSR, the idea would be that the server has access to cookies/headers that'd provide the necessary data. With SSR, pages are rendered on demand/dynamically. I understand this to be different than SSG (prerendered pages), where you'd have to rely on client side flags only, as you mentioned.
Are you using a specific framework? We have some more in-depth examples for Next.js, for example.jolly-doctor-34097
10/02/2025, 2:57 PMMyPage component where we are instantiating the growthbook instance).
This is because inside a render function, the server doesn't have access to the Request object, so it cannot retrieve cookies or headers. And this applies regardless of SSR or SSG.
I'm using Nextjs with Pages router btw.jolly-doctor-34097
10/02/2025, 2:59 PMid property (when the server performs the prerendering) 🤔jolly-doctor-34097
10/02/2025, 3:02 PMgetServerSideProps or getStaticProps and passing them as props, but this defeats the idea behind the hybrid approach.
Also, passing attributes as props is not always feasible since sometimes attributes are user-sensitive and they would be serialized and injected inside the HTML of the page..strong-mouse-55694
10/02/2025, 4:37 PM