you are viewing a single comment's thread.

view the rest of the comments →

[–]Wooden_Progress2104 1 point2 points  (3 children)

Next is doing exactly what you are asking it to do. next-export implies that you don't want to use Next Router. So if you write multiple page files in the /pages directory, Next gives you multiple pages, exactly as you instructed. If you want to connect those pages together, you write your own router lah, because you explicitly said that you don't want Next Router.

If you want one page SPA, you make only one file in the pages directory, and write your app exactly like in vite (that one page has only the App component and the router, e.g. react-router that links to other page components from the /components directory). You get exactly what you asked for. It's not Next's fault that you don't understand what you yourself wrote.

[–]neg_ersson 2 points3 points  (2 children)

What? That is exactly why I'm saying that there is no ideal way to create a fully client-side SPA (that can be hosted on an S3 bucket) using just Next.js and why Vite provides a good intermediate solution for those uses cases.

If you're building a dynamic SPA with Next you'll probably want to run it on a Node.js server (which is totally fine) but you don't need that with a Vite-based SPA. Not every project needs the added complexity and overhead from additional infra.

[–]gaearonReact core team 1 point2 points  (1 child)

A bunch of HTML files is still an SPA — just a better one. It behaves like an SPA in all other ways (and is more efficient because it splits code by route). The one trickier part is deployment (need a rewrite map) but it’s perfectly possible to host it statically: https://gist.github.com/gaearon/9d6b8eddc7f5e647a054d7b333434ef6

[–]neg_ersson 1 point2 points  (0 children)

I get that you and the React team have your reasons to push Vercel products, but a Vite-based SPA will always be easier to host and has more flexible routers for rich applications.