← All topics

Metadata, OG images & SEO files

Co-located, typed metadata APIs and file conventions.

  • export const metadata for static values or generateMetadata for dynamic ones; title.template composes titles.
  • opengraph-image.tsx renders a social card with ImageResponse (JSX to PNG).
  • sitemap.ts, robots.ts and icon.svg are file conventions that become real endpoints and tags.
  • next/font self-hosts fonts with zero layout shift; next/image optimises images.

See it in this app: src/app/layout.tsx, opengraph-image.tsx, sitemap.ts, robots.ts

export async function generateMetadata({ params }: Props): Promise<Metadata> {
  const { id } = await params;
  const project = await getProject(id);
  return { title: project?.name ?? "Project" };
}