Tutorial: Hosting your Next.js frontend on Netlify in 5 minutes
Written by Knut Melvær
If you followed the instruction of the first blog tutorial, you now already have a blog that can be hosted on any environment that runs node, be it Zeit’s now
, Heroku or your own server (bless you!). But what if you wanted to host it on an awesome static site host like Netlify? Well, look no further, here is how to go about it.
Next.js comes with the ability to export as a static standalone app. Where Next.js works as a single page application with server-side rendering out of the box, such an export will build web pages as .html-files in folders, just like the old days. You will still get most of the features like prefetching and so on though.
If you just want go check out the code, you can find it on GitHub.
1. Add the export command to package.json
This feature is available under the command next export, which you will have to add to your scripts. I chose to make a new entry, called export
, and chain it after the build step.