vercel / next.js

The React Framework
https://nextjs.org
MIT License
127.07k stars 27.01k forks source link

Issue with warning on "experimentalReact" #51911

Closed scottroot closed 1 year ago

scottroot commented 1 year ago

Verify canary release

Provide environment information

Operating System:
      Platform: linux
      Arch: x64
      Version: #42~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Apr 18 17:40:00 UTC 2
    Binaries:
      Node: 16.15.0
      npm: 8.5.5
      Yarn: N/A
      pnpm: N/A
    Relevant Packages:
      next: 13.4.8-canary.7
      eslint-config-next: 13.1.5
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 4.9.4
    Next.js Config:
      output: N/A

Which area(s) of Next.js are affected? (leave empty if unsure)

App directory (appDir: true)

Link to the code that reproduces this issue or a replay of the bug

na

To Reproduce

I am not sure what suddenly caused it so I can't create a reproducible example to post, and didn't find any documentation about experimentalReact settings anywhere to troubleshoot it.

Describe the Bug

I just started getting a warning in NextJS that Server actions require experimental.experimentalReact in the next.config.js file. But when I add that in the config, I then get another problem:

warn  - Invalid next.config.js options detected: 
warn  -     The value at .experimental has an unexpected property, experimentalReact, which is not in the list of allowed properties

In some cases it has stopped my build from completing.

Expected Behavior

Either works, or the suggestion in the warning works, or provides link to help understand and track down what the problem is.

Which browser are you using? (if relevant)

na

How are you deploying your application? (if relevant)

na

scottroot commented 1 year ago

Additional context as I am investigating more. It seems that there is some crossover between Server Actions and what was previously recommended for server side functions to prevent data leaking to client side. I have a number of functions that include "use server" at the top that I did some time in the past 6-12 months. These are only imported into app dir/page.tsx server side but I am guessing something related to this is what is causing these problems.

wwwdepot commented 1 year ago

Looks like you're not following the releases, Server Actions is new in v13.4 and requires changing next.config.js to:

module.exports = {
  experimental: {
    serverActions: true,
  },
}

https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions

previously recommended for server side functions to prevent data leaking to client side

See https://nextjs.org/docs/getting-started/react-essentials#the-server-only-package

huozhi commented 1 year ago

per above please change to experimental.serverActions, thanks

github-actions[bot] commented 1 year ago

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.