Question presented to candidate: "Our site needs a favicon, a home-screen icon, a preview image when links are shared on social media, and a web app manifest. How do you add these in a Next.js App Router project, and what does Next.js do with the files?"
What a strong answer should cover:
- Metadata files are special file names in
app/:favicon.ico(root only),iconandapple-icon,opengraph-imageandtwitter-image(with optional.alt.txt),manifest.json/.webmanifestormanifest.ts, plussitemapandrobots. - Each can be a static file or code (
.tsx/.ts) that generates it, for example withImageResponsefromnext/og. - Next.js serves each file at a URL and writes the matching
<head>tags automatically (rel icon, apple-touch-icon, og:image with type, width, height and alt, rel manifest), adding a content hash to the URL. - Files apply to their route segment and below; a deeper
opengraph-imageoverrides a parent one. - Generated files are special Route Handlers, prerendered and cached by default unless they use request data; set
metadataBaseso image URLs are absolute.
Clarifying questions expected:
- "Does each page need its own share image, or is one per site enough?" β static file versus generated per segment.
- "Do we want the site installable as a PWA?" β then the manifest needs proper icons.
Code / implementation expected: Yes β a file layout and one generated image or manifest.