Replies: 101 comments 58 replies
-
Perhaps there are dates when this is scheduled to be done? Or is it better to use Pages Router? FYI: Gatsby allows you to use dynamic routers in static exports without configuring server-side redirects. That's the only thing stopping us from moving our PWAs from Gatsby to Next.js |
Beta Was this translation helpful? Give feedback.
-
I did not see this error on 13.4.13. I started seeing it when I upgraded to 13.5.3. |
Beta Was this translation helpful? Give feedback.
-
Can confirm this is working on 13.4.13. I'm curious if the functionality is therefore a regression or a bug that's become a feature 😅 |
Beta Was this translation helpful? Give feedback.
-
But does it output the static page? If it doesn't and there is no error, then it's definitely a regression. |
Beta Was this translation helpful? Give feedback.
-
@petejodo What does "working" mean in this case? Previously there was no error message but it was failing silently. So in 13.5.0, a helpful error message was added explaining how to fix it. See #48022 (comment) for more details. However maybe there is a case when the error message shouldn't be printed? If you have code that was working with Please do NOT comment on this issue since it describes a new feature that needs to be implemented (not a regression). |
Beta Was this translation helpful? Give feedback.
-
I can confirm that this issue persisted in version 13.4.13 as well. It failed silently as you said; there was no error during the build, but accessing the dynamic route resulted in a 404 error. |
Beta Was this translation helpful? Give feedback.
-
yeah I didn't see that at first and thought that it was working in my testing but I guess I somehow messed something up in my testing where I thought it was working but it definitely was not. Sorry, my mistake! This put me in a bind because I misinterpreted the opening paragraphs to https://nextjs.org/docs/app/building-your-application/deploying/static-exports which made it seem I could port a SPA to nextjs and we just about finished porting it. That's my problem though, not yours' 😅 I think I can re-hack react-router back in even though that was giving me trouble at the start of the project |
Beta Was this translation helpful? Give feedback.
This comment was marked as off-topic.
This comment was marked as off-topic.
-
Hi, is this related to the error encountered in @leerob SPA example? The error message seems surprising, and params are meant to be obtained via page props rather than the |
Beta Was this translation helpful? Give feedback.
-
Hi, I just started learning Next.js and I want to deploy my app as static SPA on Amazon S3. Hence, I added
I'm stuck here. What am I supposed to do to get the dynamic routes working with the static export? Maybe, I'm don't fully understand |
Beta Was this translation helpful? Give feedback.
-
@goerlitz starting step 3 and 4 I think you get confused:
The thing is that if you use a dummy static param, Next only knows the dummy "/datasets/foo" route. So "/datasets/bar" won't work. You could do an URL rewrite from "/datasets/bar" to "/datasets/foo", but then the route parameter is lost. You could opt for a query parameter instead. Sadly until Next.js supports exporting dynamic routes that are not statically rendered like it did in Next 12 |
Beta Was this translation helpful? Give feedback.
-
Thanks @eric-burel for the guidance. Having worked on SPA with Api backends in the past, I thought I could make Next.js output a SPA bundle with separate api code. Actually, I think that the first paragraph in https://nextjs.org/docs/app/building-your-application/deploying/static-exports is quite misleading in that sense:
No, Next.js is not made for SPAs - it is a totally different paradigm with the goal to NOT do all rendering and routing in the browser but move more code to the server where computing is more efficient (SSR etc.). Hence, a typical Next.js app will never be an SPA (and should not be), because the application code is split up and runs on server and client likewise. IMHO, for most applications - that usually have dynamic routing - the static export does not make sense to me at all. |
Beta Was this translation helpful? Give feedback.
-
Does exists on 13.5.5 as well, I have tried to build a view with this routing structure:
on production i had issues for previous versions, [id] was not found and it was navigating to home page, and now not even able to build to the this issue:
|
Beta Was this translation helpful? Give feedback.
-
Can you please give an update, when this feature is planned? I mainly switchedto nextjs, because of the routing functionality. Now it forces me to host on a node server... As a workaround i try out useing pages router again. [https://nextjs.org/docs/pages/building-your-application/routing/pages-and-layouts] |
Beta Was this translation helpful? Give feedback.
-
@andreasfrey, this is what I meant with "Next.js follows a different paradigm" than SPA. If you are trying to use Next.js to create a traditional SPA (with dynamic routes) that can be packaged for hosting on a CDN, then you are doing something (conceptually) wrong. This is not what Next.js was designed for. If you want to move from an SPA to Next.js (with all the nice features, like SSR etc.), you should
|
Beta Was this translation helpful? Give feedback.
-
Hej, coming from #54393, I have the same issue after following the guide https://nextjs.org/docs/pages/building-your-application/upgrading/from-create-react-app#step-7-create-the-entrypoint-page to convert a CRA app into a Next one. I get many errors like |
Beta Was this translation helpful? Give feedback.
-
As people have said, with the release of v15 now with this still not being addressed, it's pretty clear this isn't going to be resolved. |
Beta Was this translation helpful? Give feedback.
-
The year is 2067. All world governments have fallen. Vercel-branded killer drones patrol the skies, searching for members of the static rendering resistance. At last, the final safehouse is located. As the rebels are dragged into the prison transport by shock troops, one cries out "It wasn't supposed to be like this! You promised we'd be able to do static rendering with the App Router!" The eyes on the commander's helmet light up as he replies: "Yes, we plan to support this for the App Router as well in the future. We don't have a defined timeline yet, so Pages Router might be a better choice for you right now." And he slams the door. |
Beta Was this translation helpful? Give feedback.
-
Workaround: This is what I did to workaround this in Readest project, an open-source cross-platform ebook reader. Readest has a Web version and a Tauri version(which requires an
I conditionally set the
And add two pages:
And at runtime route to the page for that platform accordingly with a The full change is in this commit: readest/readest@242fbf6 Updated (2024-12-25): And the App Router and the Pages Router can coexist in one project. I just moved the dynamic route page and the API route into the |
Beta Was this translation helpful? Give feedback.
-
That's true, however it won't use clientside navigation when navigating between routers. The whole page will reload and it defeats the purpose of an SPA. |
Beta Was this translation helpful? Give feedback.
-
Another possible workaround: #55393 (comment) |
Beta Was this translation helpful? Give feedback.
-
You might be interested in my solution for avoiding the Pages router for the dynamic routes here: #55393 (reply in thread) |
Beta Was this translation helpful? Give feedback.
-
Hi all, thank you for your patience, and sorry for the radio silence here. We're actively working on this problem, and we hope to integrate this feature around Next.js 15.3/15.4 in April/May, or at least share a preview. Unfortunately, this problem has many moving parts, and we want to solve it correctly, especially regarding build-time server components. @wyattjoh has already started laying the groundwork for this, so I'm really excited to finally get this going. |
Beta Was this translation helpful? Give feedback.
-
For anyone following this issue, the fix has been discussed here: vercel/next.js#discussioncomment-12351694. Hope that helps! 🚀 |
Beta Was this translation helpful? Give feedback.
-
It does look like the team has started the implementation to support this! Hopefully in 5.3 🤞🏻 |
Beta Was this translation helpful? Give feedback.
-
FYI @feedthejim We might need an SPA fall-back file and some Nginx tweaks when a page is not pre-rendered. as discussed in a remix-run issue: remix-run/react-router#12905 (comment) |
Beta Was this translation helpful? Give feedback.
-
For whoever is struggling trying to find a temporary workaround for that situation, please check this, it might be helpful somehow. |
Beta Was this translation helpful? Give feedback.
-
Oh cool, is that why I can't get this to work? |
Beta Was this translation helpful? Give feedback.
-
any update please? |
Beta Was this translation helpful? Give feedback.
-
@feedthejim Any progress on this matter? |
Beta Was this translation helpful? Give feedback.
-
Note
Jump to the latest answer from the Next.js team: #64660 (comment)
Verify canary release
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 22.5.0 Binaries: Node: 18.17.1 pnpm: 8.6.12 Relevant Packages: next: 13.4.20-canary.2 react: 18.2.0 react-dom: 18.2.0 Next.js Config: output: export
Which area(s) of Next.js are affected? (leave empty if unsure)
App Router, Static HTML Export (output: "export")
Link to the code that reproduces this issue or a replay of the bug
https://github.com/curated-tests/next-issue-48022
To Reproduce
The page in question is /app/blog-app/[slug]/page.tsx
Describe the Bug
Fails with an error:
This is expected right now because its not implemented, but it would be nice to support this so that App Router can match Pages Router.
Expected Behavior
Ideally, the build should complete and navigation should work client side.
/blog-app/
)/blog-app/one
)Which browser are you using? (if relevant)
Chrome
How are you deploying your application? (if relevant)
python3 -m http.server 3000
NEXT-1550
Beta Was this translation helpful? Give feedback.
All reactions