Migrating Create React App to Next.js

What would I need to change in order to migrate a simple Create React App project to Next.js within the same Netlify project?

  • Update build settings publish directory from build to .next via the settings page or via top level netlify.toml
  • Install the Next.js runtime plugin (without this step, I was getting a “page not found” in the deploy previews)

Are there any other configurations I’m missing? Thanks :slight_smile:

Hello @_coffee , thank for posting.
Kindly follow the official Nextjs documentation link below to learn how to Migrate Create React App to Nextjs

  • Update build settings publish directory from build to .next via the settings page or via top level netlify.toml

You can use either the build settings page in your dashboard or the netlify.toml file.

Note that for Nextjs the typical build settings are as follows. They differ depending on how your site is generated.

  • 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

Hope this helps.

2 Likes

Thanks for that awesome information, @clarnx :raised_hands:! Let us know if you have any other questions, @_coffee.

1 Like