0
votes

I want to deploy my Next.js app to my own hosting. I run next export to build the app, it works and i able to run it on my hosting server. But the problem is the app not server side rendering (reloading the app on any page except main page will cause error):

enter image description here

I'm new on Next.js and my previous apps on react can't do server side rendering, so i a bit confuse about it. Any help will be welcome, Thank You!

1
What is the error you are getting? Please provide more details.subashMahapatra
@subashMahapatra not found error, i already edit my questionPotamir

1 Answers

1
votes

According to the documentation, next export is for exporting your project into static HTML. More importantly, the docs state (emphasis mine):

next export is intended for scenarios where none of your pages have server-side or incremental data requirements (though statically-rendered pages can still fetch data on the client side just fine).

If you're looking to make a hybrid site where only some pages are prerendered to static HTML, Next.js already does that automatically for you! Read up on Automatic Static Optimization for details.

next export also causes features like Incremental Static Generation and Regeneration to be disabled, as they require next start or a serverless deployment to function.

This means that if your routes need server-side data fetching with getServerSideProps, you'll need to do run the project as a Node.js server either through Next.js (next build && next start), or with a custom node server.