Next.js Codemods for API Updates
Recipe ID
org.openrewrite.codemods.migrate.nextjs.NextJsCodemodsArtifact
org.openrewrite.recipe:rewrite-codemodsNext.js provides Codemod transformations to help upgrade your Next.js codebase when an API is updated or deprecated.
Usage
This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.codemods.migrate.nextjs.NextJsCodemodsIf the recipe isn’t available locally, install it with:
mod config recipes jar install org.openrewrite.recipe:rewrite-codemods:0.27.2Definition
This recipe runs the following recipes in order.
- Use
withRouterorg.openrewrite.codemods.migrate.nextjs.v6.UrlToWithrouter - Transform AMP HOC into page config
org.openrewrite.codemods.migrate.nextjs.v8.WithampToConfig - Transform Anonymous Components into Named Components
org.openrewrite.codemods.migrate.nextjs.v9.NameDefaultComponent - Add React imports
org.openrewrite.codemods.migrate.nextjs.v10.AddMissingReactImport - Rename Next Image Imports
org.openrewrite.codemods.migrate.nextjs.v11.CraToNext - Rename Next Image Imports
org.openrewrite.codemods.migrate.nextjs.v13_0.NextImageToLegacyImage - Migrate to the New Image Component
org.openrewrite.codemods.migrate.nextjs.v13_0.NextImageExperimental - Remove
<a>Tags From Link Componentsorg.openrewrite.codemods.migrate.nextjs.v13_0.NewLink - Use Built-in Font
org.openrewrite.codemods.migrate.nextjs.v13_2.BuiltInNextFont - Migrate
ImageResponseimportsorg.openrewrite.codemods.migrate.nextjs.v14_0.NextOgImport - Use
viewportexportorg.openrewrite.codemods.migrate.nextjs.v14_0.MetadataToViewportExport
Data tables
Structured output this recipe can produce.
- Source files that had resultsSource files that were modified by the recipe run.
org.openrewrite.table.SourcesFileResults - Source files that had search resultsSearch results that were found during the recipe run.
org.openrewrite.table.SearchResults - Source files that errored on a recipeThe details of all errors produced by a recipe run.
org.openrewrite.table.SourcesFileErrors - Recipe performanceStatistics used in analyzing the performance of recipes.
org.openrewrite.table.RecipeRunStats