Guides & Tutorials

Migrating an existing Next.js project to Netlify

Guides & Tutorials

Migrating an existing Next.js project to Netlify


So, you have a Next.js project that works flawlessly, and you want to put it on Netlify for the first time. Fun! Here's some things you might have to do.

Add a netlify.toml file

You'll need a netlify.toml file added at the top level of your project to make sure everything is imported correctly.

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

You can also do this in the Netlify UI if you don't want to make this file by filling in the build command and publish directory!

Basic build settings on Netlify, with command npm run build and directory .next

If you aren't using the defaults for your Next.js publish or functions directory, you can change the values here! For example:

  command   = "npm run build"
  functions = "my_functions_dir"
  publish   = "my_publish_dir"

If you would like to customize even more build settings, check out the docs for more information on this!

Anything else?

Honestly, probably not. Each of these steps are optional, depending on your project! We auto-install the Essential Next.js Build Plugin to all new Next.js projects on the platform, which will enable server-side rendering and other framework-specific features in your builds. If you have any problems with it, you can uninstall it, or file an issue on the repo, or ask questions in our community!

What if I don't have an existing Next.js project?

Been there! Here's a starter project for ya to get going:

Deploy to Netlify

(Clicking this button will deploy a Next.js starter project to Netlify, and clone it to your chosen Git provider, PLUS because it's brand new, you can completely ignore the previous parts of this post)

Keep reading

Recent posts

Book cover with the title Deliver web project 10 times faster with Jamstack enterprise

Deliver web projects 10× faster

Get the whitepaper