User-Agent Based SSR or SPA: Next.js vs Meta Frameworks
Unanswered
Hällefors Elkhound posted this in #help-forum
Hällefors ElkhoundOP
Hey!
I came across a website that behaves differently based on the User-Agent header.
If the request is from a crawler (like Googlebot), it returns a fully pre-rendered HTML version. But if a normal user visits it through the browser, it just serves a regular SPA.
How do you think such a codebase is structured?
Did they change how data fetching works internally based on the request type?
Or is there a way to build components that can work both in SPA mode and also be pre-rendered when needed?
I know this is totally doable with things like React Router 7, TanStack Start, or any meta-framework with universal data fetching.
But I’m wondering: is it also possible to do this in Next.js?
Or would it require serious changes to how the app is structured?
Curious to hear how you’d approach this.
I came across a website that behaves differently based on the User-Agent header.
If the request is from a crawler (like Googlebot), it returns a fully pre-rendered HTML version. But if a normal user visits it through the browser, it just serves a regular SPA.
How do you think such a codebase is structured?
Did they change how data fetching works internally based on the request type?
Or is there a way to build components that can work both in SPA mode and also be pre-rendered when needed?
I know this is totally doable with things like React Router 7, TanStack Start, or any meta-framework with universal data fetching.
But I’m wondering: is it also possible to do this in Next.js?
Or would it require serious changes to how the app is structured?
Curious to hear how you’d approach this.