Skip to content

dynamic = "force-static" does not apply when used on a page file #4

@arrofirezasatria

Description

@arrofirezasatria

When using export const dynamic = 'force-static' in a Next.js page (e.g., inside a page.tsx or page.js file within the app directory), the page does not behave as expected. It does not enforce static generation and still behaves as if it's dynamic.

Reproduction :

  1. Create a new route under app/page.tsx.

  2. Add the following:

export const dynamic = 'force-static';

export default function Page() {
  console.log("Running on server");
  return <div>Hello from static</div>;
}
  1. Run next build && next start or next dev

Expected Behaviour

The page should be statically generated at build time (similar to using getStaticProps in the old pages router) and not include any dynamic logic or server rendering at runtime.

Actual Behaviour

redirect to 404 pages and have an error message below
Unable to find `next-intl` locale because the middleware didn't run on this request and no `locale` was returned in `getRequestConfig`. See https://next-intl.dev/docs/routing/middleware#unable-to-find-locale. The `notFound()` function will be called as a result.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions