According to the docs, Netlify supports next.js through the Essential Build Plugin and manual deployments through a CLI command, but how can I use the two together to build a next.js project in my own CI and deploy only the build output to Netlify?
The plugin page mentions "linking", i.e. it assumes that the project is connected via Git repository and built by netlify, not locally by my own CI.
OK, finally got this working. Wrapping it up in case somebody else finds it useful:
netlify-cliand@netlify/plugin-nextjsnetlify.tomlin the project root as described in this section of the plugin README (make sure to have paths forpublishandfunctions;functionsis required for server-side-rendering and API handlers; both directories will be used for build output during the build).netlify(another "temp" directory) to.gitignoreto exclude the build output from your repotarget: "experimental-serverless-trace"tonext.config.jsnetlify loginto your account, runnetlify deploy --buildonce, pick a site nameNETLIFY_AUTH_TOKEN(with a "personal access token" from the Netlify UI) andNETLIFY_SITE_ID(displayed in the Netlify UI after choosing a name and successfully completing the first successful deployment) to bypass login and site selection in the future