简体   繁体   中英

How to Export NextJS Into Dynamic Pages? Not a Static HTML Pages

I am trying to export NextJs based on its official documentation. However it can be only exported into static html.

How do I export it into dynamic pages? Whenever user submit the data then its updated. Just like a normal website built with (PHP,Javascript,CSS). Meanwhile, I am trying to build it with (PHP,NextJs,CSS). I saw there are many showcase that was built by NextJS

I am doing export through this code

npm run build
npm run export

Based on its documentation https://nextjs.org/learn/excel/static-html-export

then, the outout is at 'out' folder. Surprisedly, its a static html page. Am I missing something? Thank you

I am guessing you are using php for API? and Next.JS for React but with SEO?

So under these assumptions, I am going to answer your question.

First, Next.JS supports two types of rendering.

One, is static rendering that you use for static sites. It is a bunch of static files, but unlike what you think, you can still call API, submit forms and manipulate DOM based on server data. What it doesn't support is URL based wildcard routes, some hacky tricks you may do with the queryparams etc and some other stuff. Even those are now possible with Next 9.

Two, is server side rendering, something like what you'd conventionally do with php and JS, but here with express (or hapi maybe) and next. The html is built dynamically on server side and sent to the browser just like in php contrary to the setup in the static build, where all the DOM manipulations are defined already and bundled into JS for static use.

Both these are good for SEOs and Cool to develop with.


PS After reading the @mfakhrusy comment on the question, if you are thinking of next like an alternative to conventional JavaScript with PHP in server, you may need to work on your basic knowledge of NodeJS and how Next Works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM