2.10.3. Install and launch Next.js

Next.js — open source web development framework created by Vercel that allows you to build web apps based on React with server-side rendering and static site generation. Requires Node.js to work.

  1. Install Next.js globally:
    cd ~
    mkdir .node
    cd .node
    npm install next
  2. In the "Hosting account settings" section (or "Hosting → Hosting account settings"), add an alias with the name next and the value ~/.node/node_modules/next/dist/bin/next.
  1. Go to site root directory:
    cd ~/example.com/www
  2. Install a simple app example (during installation, you can just press Enter for all prompts):
    npx create-next-app@latest
  1. In the "Site settings" section, set the following settings:
    • Web server — Node.js.
    • Node.js version — 18 or higher.
    • Traffic proxyingBy IP address.
    • Root directory — name of your app's directory (for example, my-app).
  2. In the "Node.js settings" section, disable adding the –host and –port parameters to the launch command.
  3. In your app's package.json file, in the script section, specify the start command as next start --hostname 127.*.*.* (specifying the desired IP).
  4. Launch the app and check its operation.
コンテンツ

    (8)