JavaScript SEO
Search engines can run JavaScript, but client-only rendering adds delay and risk. The safest approach is to send real HTML.
On this page · 5 min · Intermediate
On this page
- Learning objectives
- Explanation
- Code example
- Step by step
- Real-world use
- Common mistakes
- Best practices
- Remember this
- Practice exercise
- Mini quiz
- Related topics
- My notes
- Reading time
- 5 min
- Difficulty
- Intermediate
- Updated
- Oct 29, 2026
Related tutorials
Learning objectives#
- Compare CSR, SSR, SSG and prerendering
- Set unique titles and meta per route
- Use crawlable links and routes
- Test what Google sees
Explanation#
Client-side rendering (CSR) ships an empty HTML shell; content appears after JavaScript runs. Rendering may be delayed and some crawlers do not run JS at all.
Server-side rendering (SSR), static generation (SSG) and build-time prerendering send complete HTML for each URL.
Each route needs its own URL, <title>, meta description, canonical and structured data — in the HTML response, not only after hydration.
Use real <a href> links (React Router’s <Link> renders them). Avoid content that appears only after clicks or scrolling.
Code example: Per-route metadata in React#
// React 19 hoists <title>, <meta> and <link> rendered anywhere into <head>.
export default function LessonPage({ lesson }: { lesson: Lesson }) {
const url = `https://techiebabaji.com/tutorials/${lesson.id}`;
return (
<article>
<title>{`${lesson.title} | Techie Babaji`}</title>
<meta name="description" content={lesson.description} />
<link rel="canonical" href={url} />
<h1>{lesson.title}</h1>
<p>{lesson.intro}</p>
</article>
);
}
// Build step: prerender every route to static HTML (this site does this for all pages),
// so crawlers receive full content without running JavaScript.
View-source of each lesson URL shows its own title, description, canonical and full text.
This example is illustrative. Copy or download it and run it in your own environment; the expected output is shown above.
Step-by-step explanation#
- The route component outputs its own head tags.
- Prerendering turns each route into a full HTML file.
- Links are real anchors, so crawlers follow them.
- URL Inspection’s rendered HTML confirms it.
Real-world use case#
Techie Babaji prerenders every tutorial route at build time, so each lesson is fully crawlable and has unique metadata.
Common mistakes#
Every route looks the same to search engines.
Crawlers do not click. Use <a href>.
Best practices#
- SSR, SSG or prerendering for content pages
- Unique head tags per route
- Real links and URLs
- Check rendered HTML in Search Console
Remember this#
Send HTML, not an empty shell.
Unique title/meta/canonical per route.
<a href> links only.
Practice exercise#
Your task: How can you quickly check whether a page’s content is in the initial HTML?
Show solution
curl -s https://techiebabaji.com/tutorials/react/usestate-hook | grep -i "<h1"
Mini quiz#
Which approach gives crawlers full HTML without running JavaScript?
Want more? Practise all SEO MCQs · SEO interview questions
My notes#
Saved in this browser.