9 ms·
It's not the same as traditional SPA, especially with that 1 file per route setting. This is SSG and does impact how and where it can be deployed. E.g. a tradi
by re-thc 4y ago
It's not the same as traditional SPA, especially with that 1 file per route setting. This is SSG and does impact how and where it can be deployed.
E.g. a traditional SPA (client only) can handle dynamic routes without extra intervention of a higher level router.
Otherwise yes SSG can be useful :)
- Secretmapper 4y agoI think you bring up a great point! But while true, nothing really prevents one from adding their own router that handles for them that's decoupled from Next.JS and it would largely function as a traditional SPA (in that the export/'SSG' only builds one page, a la a true SPA). And that IMO is kind of where the problem is - what level of abstraction should be added? Lots of beginners had problems because they were bombarded with the many confusing things to install to make something, and more often than not routing was one of them. It's just that Next.JS' is opinionated, but I'd argue so is everything else.
- leerob 4y agoYou can still do client-only routing (it was mentioned in the tweet linked above). It can be deployed anywhere that takes HTML/CSS/JS files.
- re-thc 4y agoDan's gist clearly states you need to do rewrites yourself to make it work compared to traditional client side routed apps. If you have rewrites it is not anywhere that purely takes HTML/CSS/JS.
- cbovis 4y agoDans gist is referring to needing a routing layer to map something like `/blog/my-latest-article` to `/blog/[article].html`. This is the same of any non-React SPA. If I have `pages/blog/index.tsx` in my NextJS app this will get output to `blog.html` and can be deployed like a static site without further top-level routing.
- re-thc 4y agoMy original comment was specifically in reference to dynamic routes. You're referring to static routes. This is not the same as any non-React or non-Next SPA either way. A lot of them have SPA support i.e. route anything to index if there is no match. They may not have random rewrite support though.