javascript – How can I crate a react app with next.js using versione 12.1 instead of 13.1

If you want to create a Next.js app using a specific version of React (such as version 12.1 instead of the latest version), you can follow these steps:

  1. First, you need to install a specific version of Next.js that is compatible with the React version you want to use. You can do this by running the following command in your terminal:

npx create-next-app@latest my-app --use-npm --example "https://github.com/vercel/next-learn-starter/tree/lesson-01"

In this command, my-app is the name of your app, and –example specifies the example project you want to use as a starting point. You can replace the URL with any other Next.js example project that is compatible with version 12.1 of React.

  1. Once the installation is complete, navigate to your app directory:

cd my-app

  1. In your app directory, open the package.json file and find the dependencies section. Look for the line that specifies the version of React that is being used. It should look something like this:

"react": "^13.0.0",

Change the version number to 12.1.0, like this:

"react": "^12.1.0",

  1. Save the changes to the package.json file and run the following command to install the specific version of React:

npm install

This will install version 12.1.0 of React and any other dependencies that are required by your app.

5.Finally, you can start your app by running:

npm run dev

This will start a local development server and open your app in a web browser. You can now start building your app with version 12.1.0 of React.

Read more here: Source link