Prerendering One Page Per Device in Next.js and Matching the Cache Key
A developer explains how to prerender a static marketing page separately for each device type in the Next.js App Router, rather than serving one page to everyone. The approach lets the browser handle the choice, since the page has no per-visitor content and can be built once. A page opts in with a marker export and refuses to render at its original path, so only device-specific URLs serve it. A generator script reads the marked pages and creates one wrapper route per device, along with a list of cacheable paths. The script is set to run before development and build steps so the generated routes stay current.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in