Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4133 pages
Next.js and React

next build stops because Next.js cannot read revalidate, dynamic or another route option

Your error

⨯ Invalid segment configuration export detected. This can cause unexpected behavior from the configs not being applied. You should see the relevant failures in the logs above. Please fix them to continue.3 more lines it can show

Fix it fast

Most common cause, 1 of 3

The value is a calculation

Write the final number.

Fix
// app/blog/page.tsx
export const revalidate = 600 // 10 minutes
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

Next.js reads route options such as revalidate, dynamic and runtime by parsing the file at build time, without running it. A value written as arithmetic, an imported constant or a condition cannot be read that way, so the build stops. Write the option as a plain literal like 600 or 'force-dynamic', and move runtime decisions into code.

  • Applies to Next.js 15.5, React 19, Node.js 24
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

The last line is only a summary. Scroll up in the build output to the line that names the route and the option; it tells you which of the causes below you have.

Run this first
npx next build 2>&1 | grep -B1 -A2 "can't recognize the exported"

Then find the line you see in this list and open its fix:

  1. 1The value is a calculationUnknown identifier "..." at "revalidate", where the identifier is a local variable
  2. 2The value is imported from a shared constants fileUnknown identifier at "revalidate" naming a constant that is exported from another module
  3. 3The option depends on an environment variable or a conditionUnsupported node type "ConditionalExpression" at "dynamic"

What does the error look like?

  • ⨯ Invalid segment configuration export detected. This can cause unexpected behavior from the configs not being applied. You should see the relevant failures in the logs above. Please fix them to continue.
  • ⨯ Next.js can't recognize the exported `config` field in route "/s/page": Unknown identifier "secs" at "revalidate".
  • Unknown identifier "TEN_MIN" at "revalidate".
  • Unsupported node type "ConditionalExpression" at "dynamic".

Cause 1 of 3

The value is a calculation

You seeUnknown identifier "..." at "revalidate", where the identifier is a local variable

Check

Look for revalidate = 60 * 10, or a variable defined a few lines above. The parser only accepts a number it can see directly; the Next.js docs give 60 * 10 as an example of a value that is not accepted.

Check
grep -rnE 'export const (revalidate|dynamic|dynamicParams|fetchCache|runtime|preferredRegion|maxDuration)' app

Fix

Write the final number. A comment keeps the meaning readable.

Fix
// app/blog/page.tsx
export const revalidate = 600 // 10 minutes

Verify

Run the build again. The route appears in the route table with its revalidate time.

Verify
npx next build

Confirmed by nextjs.org

Did this fix it?

Cause 2 of 3

The value is imported from a shared constants file

You seeUnknown identifier at "revalidate" naming a constant that is exported from another module

Check

A shared constant feels tidy, but the build reads each route file on its own and does not follow the import to find the number.

Check
grep -rnE "export const revalidate = [A-Z_]+" app

Fix

Repeat the literal in each route file that needs it. If you want one place to change cache times, put the time on the fetch call or the cached function instead, where ordinary code is allowed.

Fix
// route file: literal only
export const revalidate = 600

// or keep the shared constant at the data level
import { TEN_MIN } from '@/lib/cache'
const res = await fetch(url, { next: { revalidate: TEN_MIN } })

Verify

The build passes and the route still shows the expected revalidate time.

Verify
npx next build | grep -E 'Revalidate|○|ƒ'

Confirmed by nextjs.org

Did this fix it?

Cause 3 of 3

The option depends on an environment variable or a condition

You seeUnsupported node type "ConditionalExpression" at "dynamic"

Check

A ternary on process.env, or any expression, is not a constant literal. The value would only be known when the code runs, which is after the build has to decide how to render the route.

Check
grep -rnE "export const dynamic = .*\?" app

Fix

Pick one literal for the file. If only some requests need dynamic output, leave the segment option out and call connection() in the code path that must wait for a real request.

Fix
import { connection } from 'next/server'

export default async function Page() {
  if (process.env.LIVE_DATA === '1') {
    await connection() // rendered per request from here on
  }
  return <Dashboard />
}

Verify

The build passes, and the route table shows the rendering mode you expect for the environment you built in.

Verify
LIVE_DATA=1 npx next build

Confirmed by nextjs.org

Did this fix it?

How do I stop it coming back?

  • Treat route segment options as configuration, not code: literals only.
  • Keep shared cache times at the fetch or function level, where variables are allowed.
  • Run next build in CI; next dev does not always stop on these values.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.