Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App router : ISR always regenerates dynamic routes even when called with same params #62195

Open
lolo-io opened this issue Feb 17, 2024 · 2 comments
Labels
bug Issue was opened via the bug report template.

Comments

@lolo-io
Copy link

lolo-io commented Feb 17, 2024

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/white-surf-3t2zj3?file=%2Fapp%2F%5Bslug%5D%2Fpage.tsx%3A7%2C43

To Reproduce

1- npx create-next-app@latest -> Choose App Router
2- Create a [slug] dynamic route and create a page.tsx file with a minimal content and a console.log
3- export const revalidate = 30; in [slug]/page.tsx
4- yarn build && yarn start to start a production build
5- Load localhost:3000/anyslug
6- Refresh multiple times within 30 seconds

Current vs. Expected behavior

  • Current :
    console.log outputs log on every refresh.

  • Expected :
    console.log should output log only once within a 30 seconds window.

Provide environment information

nextjs 14.1.0

Which area(s) are affected? (Select all that apply)

App Router

Which stage(s) are affected? (Select all that apply)

next start (local)

Additional context

revalidate was working as intended for dynamic routes with Page Router.

@lolo-io lolo-io added the bug Issue was opened via the bug report template. label Feb 17, 2024
@lolo-io
Copy link
Author

lolo-io commented Feb 19, 2024

I found a solution/workaround for this.

Add this to your route component to enable ISR for dynamic pages :

export const dynamicParams = true
export const generateStaticParams = async () => []

export const generateStaticParams = async () => [] will 'enable' generating static versions of pages, but generate none at build time (empty array).
export const dynamicParams = true will allow to generate pages for params that have not been generated at build time.

I think it was somehow similar with Pages Router.

I don't know if this is a workaround or the correct way things should be, so I'll leave the issue open for now but feel free to close it if this is actually not a bug.

@white0dew
Copy link

white0dew commented May 11, 2024

but your solution maybe not work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

2 participants