question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[feature request] Redirect render a hidden a tag to support SEO.

See original GitHub issue

Can I do it?

const app = <StaticRouter context={context}>XXXXXXX</StaticRouter>;
const stream = renderToNodeStream(app);
stream.pipe(res);
stream.on('end', () => {
  if (context.url) { res.redirect(context.url) }
});

No, I can not.

HTTP doesn’t support Redirect in the middle of body.

But I want to use renderToNodeStream to shorted uses’ waiting time. I want SSR for SEO too.

But many crawlers of the search engine don’t support js. They don’t know to redirect to another url without HTTP status 302.

So, why not give them an a tag?

Then:

  • Browser receives node_stream, and hydrate, and found <Redirect to={xxxx}/>, then redirect.
  • Crawler receives node_stream, found an a tag, crawl it.

Or leave what to render to user: <Redirect to={xxx}>{url => <a style={{display:'none'}} href={url} />}</Redirect>

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
timdorrcommented, Jun 7, 2018

Yes, that would work.

0reactions
xialvjuncommented, Jun 7, 2018

@timdorr You mean?

<Switch>
  <Route xxxx />
  <Route xxxx />
  <Route xxxx />
  <Route render={props => is_server ? <a href="xxxx"/> : <Redirect to="xxxx" />} />
</Switch>
Read more comments on GitHub >

github_iconTop Results From Across the Web

[feature request] Redirect render a hidden a tag to support ...
No, I can not. HTTP doesn't support Redirect in the middle of body. But I want to use renderToNodeStream to shorted uses' waiting...
Read more >
Redirects and Google Search
Redirecting URLs is the practice of resolving an existing URL to a different one, effectively telling your visitors and Google Search that a ......
Read more >
Ultimate Guide to Redirects in Technical SEO
From an SEO perspective, redirects are a way to preserve the ranking signals from the original page, which can help maintain the rankings....
Read more >
React SEO: Best Practices to Make It SEO-Friendly - Ahrefs
However, developments in both how Google and React can render JavaScript ... If you used a JavaScript feature that Googlebot didn't support, ...
Read more >
The Website Migration Guide: SEO Strategy, Process, & ...
The redirects implementation is one of the most crucial activities during a site migration. If the legacy site's URLs cease to exist and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found