Next.js and Googlebot: Key Considerations
Next.js supports SSR, SSG, and CSR. Googlebot handles server-rendered and static content reliably. Client-side rendered content requires JavaScript execution, which can introduce delays and occasional rendering failures.
For SEO-critical content, ensure it's present in the initial server-rendered HTML response. Use React Server Components (Next.js 14+) or getServerSideProps/getStaticProps in the pages router.
Automatic Sitemap Generation
// app/sitemap.ts
import { MetadataRoute } from 'next';
export default function sitemap(): MetadataRoute.Sitemap {
return [
{ url: 'https://yourdomain.com/', lastModified: new Date() },
// Add all your routes here
];
}
Robots.txt
// app/robots.ts
export default function robots() {
return {
rules: { userAgent: '*', allow: '/', disallow: ['/api/', '/dashboard'] },
sitemap: 'https://yourdomain.com/sitemap.xml',
};
}
Canonical Tags
export const metadata = {
alternates: { canonical: 'https://yourdomain.com/your-page' }
};
Structured Data
export default function Page() {
const jsonLd = { "@context": "https://schema.org", "@type": "WebPage", "name": "Page Title" };
return (
<>
<script type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }} />
{/* page content */}
</>
);
}
Sending Discovery Signals After a Deploy
After each production deploy, keep sitemap.xml current and call Indexaro's API for URL health checks or supported IndexNow notifications. Google will discover ordinary Next.js routes through crawlable links and sitemaps; reserve Google Indexing API calls for eligible JobPosting or livestream BroadcastEvent pages. See our Next.js indexing use case and Next.js integration.