Dynamic Route with Static-Site Generation (SSG) and Server-Side Rendering (SSR)

This page (/next/ssg/:id) is a dynamic route. The :id in the path can have any value.

The id of the page you are looking at is: marmot

Because the id can be anything and the page has to be different for any given id, we cannot pre-render all of the possible pages.
However, we can provide a list of ids to pre-render. Here we have given: [stoat, mink, ermine, weasel, ferret, polecat, marmot]
If you visit this route with one of those ids, you should see that the content is outdated, because it was created at build time.

If you visit a different id, the page will be rendered at request time and cached. This page has no cache invalidation set, so it will never be updated after that first request.

Good to Know: In Next.js you have the option to return a 404 for any route not in the list of pre-rendered pages, instead of rendering those pages on the fly.

Try it by updating the note here and refreshing this page.

This is the content of that note, according to this page rendered with SSG for dynamic routes:
Change this text!  Bleh!!!
And this is the value of "lastUpdated" for the note:
Wed Apr 10 2024 16:53:14 GMT+0000 (Coordinated Universal Time)

The pseudo-code for this page is:
SSGID code