Next.js Discord

Discord Forum

Split SSR & SPA for crawlers

Unanswered
Harrier posted this in #help-forum
Open in Discord
HarrierOP
Hello! I'm building a site that currently uses Zero sync engine. The trouble is that the sync engine doesn't support SSR, so it's client side only. My team want to introduce SSR for SEO and we're wondering if it's somehow possible to do SSR for web crawlers, while preserving the client side niceness of the sync engine.

What we have considered so far is to detect the crawlers on nginx level and route them to next app that is SSR first. For regular client, an SPA is served instead.

However, we're wondering - is it possible to do this all with just next alone? Quick googling didn't yield relevant results.

11 Replies

HarrierOP
Bump
HarrierOP
Bumpee
HarrierOP
Should I rephrase the question? 🤔
Carpenter wasp
On many occasions you can have both - client components does not mean that the app will only be rendered on browser. In fact most of the times client components mean, that the server will generate first round of html, send it to client where client component take over.

There are some dynamic behaviours that will disable that feature, but I would check first if you need to do any splitting, because more often than not, you don't need to do anything.

Having that said, I have no idea how zero plays with that. you may need to get default data on server-side and use zero only to update it afterwards.

I would not chase the route of giving different payload to google bot than to actual users - if Google detects that, your SEO ranking will plummet.
HarrierOP
True that client components are rendered during SSR and hydtated later.

It's more about sync engine not being able to run during server side rendering. Since this is what will fetch the data, and is completely incapable of fetching it server side as of now, this is why I thought of splitting the bots from users.

Edit: Otherwise crawler will see an data-less page, because the server was not able to fetch data during SSR.
HarrierOP
I was thinking that providing a sitemap, which points the bot to SSR pages would help the SEO, while allowing to preserve the SPA, that's until zero will implement SSR support
But you're right about SEO, the way you phrased the last line allowed me to search it a bit better.
Q: I use a JavaScript framework and my webserver serves a pre-rendered page. Is that still ok?
A: In general, websites shouldn't pre-render pages only for Google—we expect that you might pre-render pages for performance benefits for users and that you would follow progressive enhancement guidelines. If you pre-render pages, make sure that the content served to Googlebot matches the user's experience, both how it looks and how it interacts. Serving Googlebot different content than a normal user would see is considered cloaking, and would be against our Webmaster Guidelines.
Now I'm thinking - what if the search page on my site was done with zero, but individual items (products/issues/blog pages, anything that is uniquely identifiable) be done with SSR?
Carpenter wasp
Now I'm thinking - what if the search page on my site was done with zero, but individual items (products/issues/blog pages, anything that is uniquely identifiable) be done with SSR?

I would probably go this route. Zero looks like a nice solution for dynamic pages, but when you are serving e.g. landing page or blog post, that content is almost entirely static for user visit. You'll need to find a good way of caching and revalidating that cache, but that's still the best solution. You might even want to go SSG/ISR route instead of SSR for pages like that.

Search page, categorized listings etc usually can afford being more dynamic and fetching data after user enters the page. In those cases I would still think of some static/ssr-ed category name, mimage and description to feed something to search engines, but actual listed items inside would often change anyway.