Fixing A Index Page Not Found Error On A NextJS Site On Netlify
I setup a new Next.js site on Netlify that didn't quite work out of the box. When I did the deploy, I'd get "Page Not Found" on the home page. I'm not sure, but I think the reason is because I pointed Netlify at the GitHub repo before I pushed up the next.js code.
The things I needed to do for the fix were:
1. In the UI under "Site Settings - Build and Deploy - Continuous Deployment - Build Settings" set:
- Base directory: `/` - Build command: `npm run build` - Publish direcotry: `/.next`
2. Under "Plugins", install the "Essential Next.js" plugin for the site.
With those change the next push/deploy got things working as expected.
NOTE: I think it's also possible to install the plugin as a module directly in your development environment with this instead of installing the plugin from the UI: