
How to deploy static Nextjs app Cpanel
Reading time: min
Content List
After setting up your application on localhost, it time to deploy your next js to your cPanel, but it's not without challenge
The first step would be to prepare your next.js web pages for to deploy as html files beside the other assets required, if you haven’t, check this link Setup next.js for static exporting
Then check your package.json build script to
The run the npm run build in your terminal
If you get an Error like this:
Image Optimization using Next.js’ default loader is not compatible with `next export`.
Then create a next.config.js if you haven’t already, and add the following script to module.exports
images: {loader: ‘akamai’,path: ‘/’,}
If the command is successful, then you should see a folder generated named out
And there should be static html files generated, such as index.html, like this:
now move the content of the folder or the whole folder to the directory of your cPanel as you wish such as the public_html
The next important step is to setup the .htaccess in your directory properly, so if you have copied the content of the out folder to the public_html for example, you can setup the .htaccess as the following query
Was this page helpful?
What was the most helpful point of this page for you?
Thanks for your cooperation!
Excellent post. I definitely appreciate this website. Thanks!
Hi
Thanks for great posting
By the way how to resolve i18n next export error?
Error: i18n support is not compatible with next export. See here for more info on deploying: https://nextjs.org/docs/deployment
Did you meet before? How to resolve..?
Hope you good resolution..
Thank you
Hi there, happy to help.
Would you be able to provide more information on the problem, if you may? at what point did you get the error? while exporting? or after deployment? or in the middle of the dev process?
And if you’ve already come up with a solution, We would love to hear your story on how you solved it.