Deploy NextJS app without remote repository

So I have a NextJS app with build output in .next folder. I am using “browse to upload” files option to upload project files. But the deployment is not triggering. I have even added netlify.toml file with the following contents:

  command = "npm run build"
  publish = ".next"

  package = "@netlify/plugin-nextjs"

How to make it work?

Hi @ankitverma31, thanks for the post and welcome.
There are two ways of building Next.js applications.

  • For apps that use server-side rendering and Next.js Runtime:

    • Build command: next build
    • Publish directory: .next
  • For apps that use static HTML export:

    • Build command: next build && next export
    • Publish directory: out

If you want to use server-side rendering the proper way to deploy your application to Netlify is to deploy from a git repository.
Note that you can also deploy from a git repository using static HTML export

If you want to use the “browse to upload” files option, then you have to build your Next.js site locally on your computer using the static HTML export method.
Once you build locally (next build && next export), an out folder will be created.
You can drag and drop the out folder using the “browse to upload” files option.

You can read more on Next.js deployments using the link below.

Also for more information on Next.js Static Exports you can visit the link below.

Hope the above helps.


Is SSR possible through file upload by including netlify.toml file?

Hi @ankitverma31 if you want to use SSR, it is not possible to deploy using the file upload method.
However if you still want to deploy your Next.js site without a git repository another alternative is to deploy using the Netlify CLI method.

Kindly visit the blog post below and then scroll down to the Option 1: Use the Netlify CLI section to learn how to deploy Next.js using the Netlify CLI.

For more information about Netlify CLI, kindly visit the link below.

You can also visit the link below for a thorough guide on how to manually deploy Next.js to Netlify using the Netlify CLI

Let me know the outcome.