Course outline

Next.js / Intermediate: authority, freshness and route experience / Lesson 14

Static parameters and unlisted paths

Generate known App Router paths at build time and explicitly test the policy for unlisted parameters.

About 19 min read20 worked examples20 practice exercisesContent reviewed
On this page

Lesson goals

  • Generate parameter objects for a dynamic segment.
  • Distinguish generated and unlisted paths.
  • Verify build, freshness and deployment assumptions.
  • Design a public static-parameter set with explicit unlisted-path behavior.
  • Separate path generation, record eligibility and existing-page freshness.

Select known public paths

A dynamic route can provide parameter values ahead of time using generateStaticParams. This can pre-render known public pages during the build instead of waiting for their first request. Decide which records are appropriate for build output and how new records become available. Never include private per-user records simply because they are convenient to enumerate at build time.

Define a controlled source

The sample uses a small local array so its build inputs are explicit and no network access is required. In a real application validate external records and handle source failures before generating paths. Stable, unique slugs are part of the route contract. This data module and the page below are illustrative fragments inside a compatible Next.js application.

javascript Synthetic local route data
export const articles = [
  { slug: "start", title: "Getting started" },
  { slug: "practice", title: "Practice" },
];
Expected output
The sample contains start and practice.

The two public records supply the known slugs and titles used by the page.

Generate and render known paths

In the traditional route-segment configuration shown here, dynamicParams false rejects paths omitted from the generated list. The page awaits params and still checks the record before displaying it. The segment configuration options have different availability when Cache Components is enabled, so do not apply this policy unchanged to that mode. Consult the documentation for the installed version.

jsx App Router dynamic page fragment
import { notFound } from "next/navigation";
import { articles } from "./articles";
export const dynamicParams = false;
export function generateStaticParams() {
  return articles.map(({ slug }) => ({ slug }));
}
export default async function Page({ params }) {
  const { slug } = await params;
  const article = articles.find(item => item.slug === slug);
  if (!article) notFound();
  return <main><h1>{article.title}</h1></main>;
}
Expected output
/articles/start displays Getting started.

The generator returns one object per slug; the page renders the matching synthetic article.

Plan freshness and deployment

A generated path list is not automatically rebuilt every time a page is revalidated. Plan how newly published slugs enter the list and how existing page data becomes fresh under the chosen cache policy. Static export has additional restrictions on request-time features and unlisted dynamic paths. Select a deployment mode deliberately rather than assuming the development server behaves like a static host.

Verify known and unknown paths

Run a production build in a controlled project, request both listed paths and an unlisted path, and inspect the generated behavior under the configured mode. Change the source list and verify the chosen release process makes a new slug available. Test malformed or duplicate source slugs before deployment. A local successful build is evidence for that configuration, not proof of behavior on every hosting platform.

Choose a finite public path set deliberately

generateStaticParams supplies parameter combinations for dynamic segments that the application can know ahead of time. Start by deciding which records are genuinely public, stable enough for the chosen deployment and available to the build process. Do not enumerate private tenant identifiers merely because they are convenient to query. A generated path is a rendering decision, not an authorization grant, and the underlying data boundary still needs the correct audience and validation.

The course uses the dated Next 16.4.3 App Router baseline with cacheComponents:false and the traditional dynamicParams setting. With dynamicParams=false in the lesson’s stated configuration, an unlisted path is rejected; verify the actual production response in the intended deployment. The examples are synthetic and unexecuted and do not claim a Next build, server or hosting test.

Match generated objects to route parameters

For app/courses/[slug]/page.tsx, the generator returns objects containing slug values, such as { slug: "intro" }. Nested dynamic segments require the relevant parameter combinations and careful ownership of parent and child generation. Check duplicates, invalid slugs and source failures before treating the output as a release input. A folder name and an object key must agree; returning a title field instead of slug does not supply the required segment.

The page receives params asynchronously under the selected baseline and should await and validate its value before loading data. A generated value may be syntactically valid while its record is later removed, unpublished or no longer eligible. Define the not-found or safe error behavior for that change. Test the actual build and direct request rather than assuming a local array model establishes framework routing.

Define unlisted paths and deployment behavior

The meaning of an unlisted parameter depends on route configuration and deployment mode. In this lesson’s traditional configuration, dynamicParams=false means paths not returned by the generator are rejected. Do not generalize that rule to another mode or to a framework version without checking its documentation. A listed path is not necessarily available forever: the source, deployment artifact or host can change.

Plan a safe public response for unknown or removed content and keep source outages distinct from genuine absence. A direct deep-link request reaches the host and must be tested in the intended deployment, not only through in-app navigation. If the application needs newly published paths without a rebuild, verify the selected deployment’s supported strategy rather than assuming the existing finite path list expands automatically.

Separate new paths from existing content refresh

Revalidating an existing page and discovering a new dynamic path are different lifecycle questions. Do not assume that a refresh of an existing page necessarily reruns generateStaticParams or adds newly published slugs. Document how a new path enters the deployable set under the selected configuration and how an existing page’s data becomes current. A short cache lifetime or a tag operation is not a substitute for that release plan.

Use a reviewed public source at build time and record its revision. If the source changes during or after the build, define which snapshot the artifact represents and how a later release or supported on-demand path handles the difference. Avoid embedding account-specific data into a shared static artifact. Cache audience, server authorization and source freshness remain independent from the generator’s list.

Test the generator and its consumers separately

A pure model can filter synthetic public records and map them to slug objects. It cannot establish that Next invoked the generator, that dynamicParams behaved as expected in production or that the host served the resulting artifact. Build an isolated compatible project and request a known path, an unlisted path and a removed record under the intended deployment mode. Inspect status and body rather than inferring transport behavior from a local array.

Also test duplicate source ids, malformed slugs, source outage and a newly published record after the build. Verify that private records are excluded and that public output contains only approved fields. Record the exact version, configuration, source revision and observations. The worked examples are explanatory fixtures; they do not claim a build, network request, cache store or production deployment was executed.

20 worked examples

1. Generate known public slugs

Problem: Map a controlled list into route parameters.

  1. Each public record contributes its slug value.
  2. The returned object key matches the dynamic segment name.
javascript Illustrative Next 16.4.3 static-parameter fixture.
const publicCourses = [{ slug: "intro" }, { slug: "advanced" }]
const params = publicCourses.map(course => ({ slug: course.slug }))

This contextual example is not executed; a compatible Next production build and intended host are required where applicable.

Expected result: The generated model contains { slug: "intro" } and { slug: "advanced" }.

Why this result follows: A generator input must match the route parameter contract.

2. Unlisted slug with dynamicParams false

Problem: Apply the lesson’s traditional route policy.

  1. The generated set contains only intro.
  2. dynamicParams=false applies the stated unlisted-path policy.
typescript Illustrative Next 16.4.3 static-parameter fixture.
export const dynamicParams = false
export function generateStaticParams() { return [{ slug: "intro" }] }

This contextual example is not executed; a compatible Next production build and intended host are required where applicable.

Expected result: Under this configuration, an unlisted slug is rejected; verify the production response in the intended deployment.

Why this result follows: The selected route configuration defines behavior outside the generated set.

3. Private record excluded

Problem: Keep a tenant-specific course out of a public path list.

  1. The first record satisfies the public audience rule.
  2. The tenant-specific record does not satisfy that rule.
text Illustrative Next 16.4.3 static-parameter fixture.
Source: intro public; private-a tenant A only
Generator policy: public records only

This contextual example is not executed; a compatible Next production build and intended host are required where applicable.

Expected result: The generated public list includes intro and excludes private-a.

Why this result follows: Build-time path selection must respect the representation’s audience.

4. Generator key mismatch

Problem: Identify an object that does not match the segment name.

  1. The dynamic folder names the parameter slug.
  2. The returned object contains title instead.
text Illustrative Next 16.4.3 static-parameter fixture.
Route: app/courses/[slug]/page.tsx
Returned item: { title: "Intro" }

This contextual example is not executed; a compatible Next production build and intended host are required where applicable.

Expected result: The item does not provide the required slug parameter for this route contract.

Why this result follows: Generated parameter keys must correspond to the dynamic segment.

5. Refresh is not path discovery

Problem: Separate an existing page refresh from adding a new slug.

  1. Refreshing an existing representation addresses its data lifecycle.
  2. The new slug requires a separate supported path-generation or deployment plan.
text Illustrative Next 16.4.3 static-parameter fixture.
Built paths: intro
Later source adds: advanced
Existing intro page is revalidated

This contextual example is not executed; a compatible Next production build and intended host are required where applicable.

Expected result: Do not assume the revalidation adds advanced to the generated path set.

Why this result follows: Existing content freshness and new-path availability are distinct concerns.

6. Await a generated slug

Problem: Resolve the page parameter before reading it.

  1. The page awaits the asynchronous params object.
  2. The resolved slug supplies the displayed value.
tsx Illustrative Next 16.4.3 static-parameter fixture.
export default async function Page({ params }: { params: Promise<{ slug: string }> }) {
  const { slug } = await params
  return <h1>Course {slug}</h1>
}

This contextual example is not executed; a compatible Next production build and intended host are required where applicable.

Expected result: For slug intro, the intended heading is Course intro.

Why this result follows: Parameter resolution precedes use in the selected baseline.

7. Duplicate generated values

Problem: Detect repeated public paths before a build.

  1. The set keeps one copy of each distinct string.
  2. Its size is smaller than the input length.
javascript Illustrative Next 16.4.3 static-parameter fixture.
const slugs = ["intro", "intro", "advanced"]
const unique = new Set(slugs)
// unique.size is 2 while slugs.length is 3.

This contextual example is not executed; a compatible Next production build and intended host are required where applicable.

Expected result: The source contains a duplicate intro value and should be reviewed under the generator contract.

Why this result follows: A local uniqueness check can reveal duplicate source identities.

8. Malformed slug

Problem: Reject an unsafe or unsupported domain identifier.

  1. The value contains characters outside the allowed pattern.
  2. A passing slug would still require publication and authorization checks.
javascript Illustrative Next 16.4.3 static-parameter fixture.
function validSlug(value) { return /^[a-z0-9-]+$/.test(value) }
// validSlug("../admin") is false.

This contextual example is not executed; a compatible Next production build and intended host are required where applicable.

Expected result: The supplied value fails the illustrative slug rule.

Why this result follows: Syntax validation is one gate, not a complete access policy.

9. Nested parameter combinations

Problem: Map a course and lesson pair to a path.

  1. The course value fills the first dynamic segment.
  2. The lesson value fills the second dynamic segment.
text Illustrative Next 16.4.3 static-parameter fixture.
Route: /courses/[course]/lessons/[lesson]
Generated pair: { course: "intro", lesson: "setup" }

This contextual example is not executed; a compatible Next production build and intended host are required where applicable.

Expected result: The example path is /courses/intro/lessons/setup.

Why this result follows: Nested paths need a complete, correctly named parameter combination.

10. Removed after generation

Problem: Handle a listed slug whose record is no longer public.

  1. The build-time list reflects an earlier source state.
  2. Current publication eligibility has changed in the fixture.
text Illustrative Next 16.4.3 static-parameter fixture.
Generated slug: intro
Later lookup: intro unpublished
Policy: unpublished content is not public

This contextual example is not executed; a compatible Next production build and intended host are required where applicable.

Expected result: The page must not expose the unpublished record; follow the documented safe absence or denial policy.

Why this result follows: A generated path is not a permanent authorization grant.

11. Source outage at build

Problem: Distinguish unavailable source from an empty catalog.

  1. The source failure does not establish that there are zero public records.
  2. The release contract requires a known input set.
text Illustrative Next 16.4.3 static-parameter fixture.
Generator source request: fails
Public records: unknown
Policy: fail the release build

This contextual example is not executed; a compatible Next production build and intended host are required where applicable.

Expected result: The build process should report failure rather than silently generating an empty set under this policy.

Why this result follows: A controlled source failure must not be mislabeled as valid absence.

12. Source revision record

Problem: Identify which catalog snapshot produced an artifact.

  1. The source revision is recorded with the generated values.
  2. The artifact identity links that input to a candidate.
text Illustrative Next 16.4.3 static-parameter fixture.
Build input revision: R12
Generated slugs: intro, advanced
Artifact: H1

This contextual example is not executed; a compatible Next production build and intended host are required where applicable.

Expected result: The release record associates H1 with the R12 path set in this model.

Why this result follows: Recording build inputs makes later path differences diagnosable.

13. New slug after build

Problem: Plan availability for a newly published course.

  1. advanced was not in the built set.
  2. The selected policy rejects unlisted paths.
text Illustrative Next 16.4.3 static-parameter fixture.
Built set: intro
Later source: intro, advanced
Configuration: dynamicParams=false

This contextual example is not executed; a compatible Next production build and intended host are required where applicable.

Expected result: The application needs its documented rebuild or supported deployment strategy before claiming advanced is available.

Why this result follows: New-path availability is a release and route-configuration concern.

14. Refresh existing content

Problem: Separate a title change from a new path.

  1. The public path already exists in the set.
  2. The changed title is content of that existing path.
text Illustrative Next 16.4.3 static-parameter fixture.
Existing path: /courses/intro
Title changes from Draft to Final
Refresh policy: configured for that page

This contextual example is not executed; a compatible Next production build and intended host are required where applicable.

Expected result: The existing representation needs its documented refresh; that alone does not define how new slugs are added.

Why this result follows: Content freshness and path discovery are separate lifecycles.

15. Valid slug, unauthorized record

Problem: Do not treat generated syntax as access permission.

  1. The syntax rule says nothing about caller eligibility.
  2. The record’s audience policy denies this caller.
text Illustrative Next 16.4.3 static-parameter fixture.
Slug: private-a
Shape: valid
Caller: not eligible
Record: private

This contextual example is not executed; a compatible Next production build and intended host are required where applicable.

Expected result: The server must not expose the record merely because the slug is well formed.

Why this result follows: A path parameter is input, not an authorization grant.

16. Static artifact privacy

Problem: Keep user-specific data out of a shared page.

  1. Every recipient of the shared artifact can inspect its content.
  2. The note is authorized only for account A.
text Illustrative Next 16.4.3 static-parameter fixture.
Proposed built page: includes account A’s private note
Audience: all visitors

This contextual example is not executed; a compatible Next production build and intended host are required where applicable.

Expected result: Exclude the private note or use an appropriate request-specific design; a shared artifact would disclose it.

Why this result follows: Build-time output must match the audience allowed to receive it.

17. Known-path direct request

Problem: Plan a production-like host verification.

  1. The request directly exercises the generated destination.
  2. Status and content are separate observations from a local path model.
text Illustrative Next 16.4.3 static-parameter fixture.
Built slug: intro
Request: GET /courses/intro
Checks: status, body, assets

This contextual example is not executed; a compatible Next production build and intended host are required where applicable.

Expected result: The isolated test should observe the intended course response and required assets for the known path.

Why this result follows: A host test verifies delivery of the actual artifact.

18. Unlisted-path direct request

Problem: Verify rejection under the selected policy.

  1. unknown is absent from the generated set.
  2. The selected traditional policy rejects unlisted values.
text Illustrative Next 16.4.3 static-parameter fixture.
Generated: intro
dynamicParams: false
Request: GET /courses/unknown

This contextual example is not executed; a compatible Next production build and intended host are required where applicable.

Expected result: The configured application should reject the unlisted path; record the actual status and body from the intended deployment.

Why this result follows: Framework and host integration establish the observed transport outcome.

19. Generator test limit

Problem: Interpret a passing local map of records to params.

  1. The local function does not invoke the Next build.
  2. No direct request or deployment was observed.
text Illustrative Next 16.4.3 static-parameter fixture.
Pure model: public records map to slug objects
Next production build: not run

This contextual example is not executed; a compatible Next production build and intended host are required where applicable.

Expected result: The test supports the mapping rule only, not actual generation or host delivery.

Why this result follows: A model’s evidence is limited to its exercised boundary.

20. Build and source race

Problem: Review a source update during path generation.

  1. The generated list was based on the earlier revision.
  2. The later source change does not retroactively rewrite the recorded artifact.
text Illustrative Next 16.4.3 static-parameter fixture.
Build reads source revision R1
Source changes to R2 before deployment
Artifact records R1

This contextual example is not executed; a compatible Next production build and intended host are required where applicable.

Expected result: The artifact should be reviewed as representing R1 and updated through the documented release strategy.

Why this result follows: A recorded source snapshot makes path freshness assumptions explicit.

Common errors and fixes

A new article URL remains unavailable.

Why it happens
Its slug was not included in the generated list under the selected policy.
How to fix it
Update the source and perform the documented release or generation step.
Prevent it next time
Test new-record publication end to end.

Private records appear in generated output.

Why it happens
Build-time enumeration included data not intended for all recipients.
How to fix it
Remove private data from public generation and review access.
Prevent it next time
Classify source data before building paths.

A segment option behaves unexpectedly in another cache mode.

Why it happens
The application uses a different configuration contract.
How to fix it
Follow the installed version’s documentation for that mode.
Prevent it next time
Record cache mode and deployment assumptions with tests.

20 practice exercises

1. With the example policy, what should happen for an unlisted slug?

Show hint

Compare the requested slug with the generated set and selected route setting.

Show worked solution

The traditional dynamicParams false configuration rejects an unlisted path. Verify the actual response with a production build in the intended deployment mode.

With the example’s traditional dynamicParams=false configuration, an unlisted slug is rejected. Verify the actual response with a production build in the intended deployment mode rather than inferring status from a local model.

Check your solution

  • The slug is absent from the generated set.
  • The production-like response is observed.

2. Does revalidating an existing page necessarily rerun the path generator?

Show hint

Refreshing existing content and discovering a new path are different lifecycles.

Show worked solution

No. Plan separately for adding new paths and refreshing existing content; consult the current documentation for the selected mode and deployment.

Revalidating an existing page does not necessarily rerun generateStaticParams. Plan how new paths enter the deployment separately from existing-page freshness and consult the selected mode’s documentation.

Check your solution

  • The new-path process is explicit.
  • Existing content refresh is tested separately.

3. A route is /courses/[slug] and the public source contains intro and advanced. What objects are generated?

Show hint

Match the dynamic segment key.

Show worked solution

Return objects with slug values intro and advanced, such as [{ slug: "intro" }, { slug: "advanced" }]. Validate the source and verify the actual production build separately.

Check your solution

  • Each object contains slug.
  • The values match the reviewed public records.

4. The generator returns { title: "Intro" } for a [slug] segment. What is missing?

Show hint

The parameter key must match the folder.

Show worked solution

The object lacks the required slug value. Map the source title or identifier deliberately to a validated slug field and test the route in a compatible Next build.

Check your solution

  • The generated object has a slug key.
  • The value satisfies the domain rule.

5. A source contains a public course and a private tenant course. Which may enter a public static set?

Show hint

Build output has an audience.

Show worked solution

Include only records approved for the shared public representation. Keep tenant-specific content out of the public artifact and enforce access at the server boundary where needed.

Check your solution

  • The public record is included.
  • The private record is excluded.

6. dynamicParams=false and only intro is generated. What happens to an unlisted slug under this policy?

Show hint

Compare the requested value with the set.

Show worked solution

The unlisted slug is rejected under the lesson’s traditional configuration. Verify the actual status and body with a production build on the intended host.

Check your solution

  • The unknown slug is absent from the set.
  • The deployed response is observed.

7. A generated slug is valid but its record becomes unpublished. May the page expose it?

Show hint

Path generation is not permanent authorization.

Show worked solution

No. Apply the current publication and object policy when the record is resolved, and use the documented safe absence or denial behavior. Test the changed source state.

Check your solution

  • The unpublished record is not disclosed.
  • The public outcome follows policy.

8. The source contains intro twice. What should the generator review?

Show hint

Check identity uniqueness.

Show worked solution

Detect and resolve duplicate slugs according to the source contract before relying on the generated list. Test the actual build rather than assuming a set operation alone proves framework behavior.

Check your solution

  • The duplicate is identified.
  • The intended generated paths are unique.

9. A slug is ../admin but the domain accepts lowercase letters, digits and hyphens. Decide.

Show hint

Validate the domain shape.

Show worked solution

Reject the malformed slug before using it as a course identifier. A passing syntax check still requires publication and caller eligibility checks where relevant.

Check your solution

  • The malformed value fails the rule.
  • Authorization remains separate.

10. A nested route has [course] and [lesson]. What must a generated pair contain?

Show hint

Provide both named segments.

Show worked solution

Return a complete combination with course and lesson values matching the dynamic folder names. Verify a concrete URL and validate the associated records under the application policy.

Check your solution

  • Both parameter keys are present.
  • The pair maps to the intended nested path.

11. A Next 16 page receives generated params asynchronously. How does it read slug?

Show hint

Await before destructuring.

Show worked solution

Await params in the async page, then validate the resolved slug and load the appropriate public record. Test a known path and a missing or changed record.

Check your solution

  • The page awaits params.
  • The resolved value is checked before use.

12. The generator source times out. Should an empty public catalog be assumed?

Show hint

Failure is not an empty result.

Show worked solution

No. Follow the release’s documented failure policy, such as failing the build, rather than silently treating unknown data as no records. Test the source-outage case separately.

Check your solution

  • The outage is identified as failure.
  • The path set is not silently emptied.

13. A build used source revision R12. Why record it with artifact H1?

Show hint

The source can change later.

Show worked solution

The revision identifies the catalog snapshot used to generate the candidate’s paths. Record it with the artifact and use a documented release strategy when the source changes.

Check your solution

  • H1 is associated with R12.
  • Later source changes are traceable.

14. A new public slug appears after a dynamicParams=false build. How does it become available?

Show hint

The existing list does not expand by assertion.

Show worked solution

Use the selected deployment’s documented rebuild or supported path-generation strategy and verify the new direct URL. Do not assume refreshing an existing page reruns the generator.

Check your solution

  • The new slug has an explicit release path.
  • Its direct response is tested.

15. An existing course title changes. Is this the same problem as adding a slug?

Show hint

Content freshness and path discovery differ.

Show worked solution

No. Refresh the existing representation according to its data policy and separately plan how newly published paths enter the allowed set. Test both lifecycles.

Check your solution

  • The existing title refresh is defined.
  • New-path availability is handled separately.

16. A valid slug names a private course for another account. What must the server enforce?

Show hint

A route value is not permission.

Show worked solution

Deny the ineligible caller and avoid exposing the record or metadata. Test the same identifier under eligible and ineligible synthetic identities at the actual server boundary.

Check your solution

  • The unauthorized caller is denied.
  • Private fields are not returned.

17. A shared built page contains account A’s private note. Why is that unsafe?

Show hint

Every recipient can inspect the artifact.

Show worked solution

A public static artifact would disclose the note to visitors outside A’s audience. Exclude it or choose an appropriate request-specific design with authorization and cache isolation.

Check your solution

  • The shared artifact contains no private note.
  • The personalized path has an appropriate boundary.

18. A known generated path works through an in-app link. What direct-host check remains?

Show hint

Copied URLs can start at the host.

Show worked solution

Request the deep URL directly and refresh it on the intended production-like host, inspecting status, body and assets. An in-app transition does not establish direct delivery.

Check your solution

  • The direct path is tested.
  • Required assets are delivered correctly.

19. An unlisted path is rejected in a local model. Does that establish the production status?

Show hint

The model is not the framework host.

Show worked solution

No. Build the compatible Next application with the selected configuration and inspect the actual response in the intended deployment mode. Record status and body separately.

Check your solution

  • The production-like response is observed.
  • The local model claim stays narrow.

20. A pure generator mapping test passes. What remains before claiming a working release?

Show hint

The function test does not build or deploy.

Show worked solution

Verify source eligibility, the actual generated artifact, known and unknown direct requests, and route behavior on the intended host. Report which checks were performed rather than inventing execution.

Check your solution

  • The actual artifact is identified.
  • Host and audience behavior have evidence.

Key takeaways

  • Generate only appropriate public parameter values.
  • Define behavior for paths outside the list.
  • Test build, freshness and hosting assumptions.
  • Generated paths do not authorize private data.
  • dynamicParams behavior depends on the selected route configuration.
  • Refreshing an existing page does not necessarily discover new paths.

Official references