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 */}
</>
);
}
Submitting to Google via Indexaro
Integrate URL submission into your deployment pipeline. After each deploy, call Indexaro's API to submit changed pages to Google, Bing, and Yandex. With Vercel, use post-deployment hooks. With self-hosted CI/CD, add a deploy step that calls the Indexaro REST API. See our Next.js indexing use case and Next.js integration for patterns.