microsoft / fluentui

Fluent UI web represents a collection of utilities, React components, and web components for building web applications.
https://react.fluentui.dev
Other
18.52k stars 2.73k forks source link

[Bug]: v9 components are forbidden in the RSC within SSR setup( next - appdir) #32832

Closed zailic closed 1 month ago

zailic commented 1 month ago

Library

React Components / v9 (@fluentui/react-components)

System Info

OS: Linux 6.1 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
CPU: (4) x64 AMD EPYC
Memory: 3.43 GB / 8.01 GB
Container: Yes
Shell: Unknown

Are you reporting an Accessibility issue?

None

Reproduction

CodeSandbox Sample

Bug Description

Actual Behavior

I'm pretty sure the SSR setup recipe from fluentuiv9 docs it worked at some point, but it seems this is no longer valid: When I'm trying to run it, the next server reports an error like the screenshot above: Screenshot 2024-09-13 222958 Of course if I'm adding the 'use client' directive the error will go away, but this will transform a server component into a client component and this is not what I want.

Expected Behavior

V9 components should be allowed into RSC, as you mentioned on the docs: Screenshot 2024-09-13 225327

Logs

createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/RendererContext.esm.js:18:73)
    at (rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/RendererContext.esm.js (/project/sandbox/.next/server/vendor-chunks/@griffel+react@1.5.25_react@18.3.1.js:170:1)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/makeStyles.esm.js:7:81)
    at (rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/makeStyles.esm.js (/project/sandbox/.next/server/vendor-chunks/@griffel+react@1.5.25_react@18.3.1.js:270:1)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/index.esm.js:23:76)
    at (rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/index.esm.js (/project/sandbox/.next/server/vendor-chunks/@griffel+react@1.5.25_react@18.3.1.js:230:1)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@fluentui+react-components@9.54.15_@types+react-dom@18.3.0_@types+react@18.3.5_react-dom@18.3_jgwnwapdklhjslg6kgd3ybekpy/node_modules/@fluentui/react-components/lib-commonjs/index.js:3080:16)
    at (rsc)/./node_modules/.pnpm/@fluentui+react-components@9.54.15_@types+react-dom@18.3.0_@types+react@18.3.5_react-dom@18.3_jgwnwapdklhjslg6kgd3ybekpy/node_modules/@fluentui/react-components/lib-commonjs/index.js (/project/sandbox/.next/server/vendor-chunks/@fluentui+react-components@9.54.15_@types+react-dom@18.3.0_@types+react@18.3.5_react-dom@18.3_jgwnwapdklhjslg6kgd3ybekpy.js:30:1)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(rsc)/./app/page.tsx:9:84)
    at (rsc)/./app/page.tsx (/project/sandbox/.next/server/app/page.js:162:1)
    at Function.__webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at async e7 (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:396658)
    at async tS (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:400214)
    at async tw (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:400775)
    at async tw (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:400906)
    at async tO (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:36:2320)
    at async /project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:36:2989 {
  digest: '1104297394'
}
 ⨯ createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (./app/page.tsx:9:84)
    at (rsc)/./app/page.tsx (/project/sandbox/.next/server/app/page.js:162:1)
    at Function.__webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at async Promise.all (index 0)
digest: "1650754739"
 ⨯ createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (./app/page.tsx:9:84)
    at (rsc)/./app/page.tsx (/project/sandbox/.next/server/app/page.js:162:1)
    at Function.__webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at async Promise.all (index 0)
digest: "1650754739"
 ⨯ createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (./app/page.tsx:9:84)
    at (rsc)/./app/page.tsx (/project/sandbox/.next/server/app/page.js:162:1)
    at Function.__webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
digest: "1104297394"
 ⨯ createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/RendererContext.esm.js:18:73)
    at (rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/RendererContext.esm.js (/project/sandbox/.next/server/vendor-chunks/@griffel+react@1.5.25_react@18.3.1.js:170:1)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/makeStyles.esm.js:7:81)
    at (rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/makeStyles.esm.js (/project/sandbox/.next/server/vendor-chunks/@griffel+react@1.5.25_react@18.3.1.js:270:1)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/index.esm.js:23:76)
    at (rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/index.esm.js (/project/sandbox/.next/server/vendor-chunks/@griffel+react@1.5.25_react@18.3.1.js:230:1)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@fluentui+react-components@9.54.15_@types+react-dom@18.3.0_@types+react@18.3.5_react-dom@18.3_jgwnwapdklhjslg6kgd3ybekpy/node_modules/@fluentui/react-components/lib-commonjs/index.js:3080:16)
    at (rsc)/./node_modules/.pnpm/@fluentui+react-components@9.54.15_@types+react-dom@18.3.0_@types+react@18.3.5_react-dom@18.3_jgwnwapdklhjslg6kgd3ybekpy/node_modules/@fluentui/react-components/lib-commonjs/index.js (/project/sandbox/.next/server/vendor-chunks/@fluentui+react-components@9.54.15_@types+react-dom@18.3.0_@types+react@18.3.5_react-dom@18.3_jgwnwapdklhjslg6kgd3ybekpy.js:30:1)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(rsc)/./app/page.tsx:9:84)
    at (rsc)/./app/page.tsx (/project/sandbox/.next/server/app/page.js:162:1)
    at Function.__webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at async e7 (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:396658)
    at async tS (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:400214)
    at async tw (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:400775)
    at async tw (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:400906)
    at async tO (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:36:2320)
    at async /project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:36:2989 {
  digest: '1104297394',
  page: '/'
}
 ○ Compiling /_error ...
 ✓ Compiled /_error in 41.5s (6495 modules)
 GET / 500 in 83966ms
 ⨯ createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (./app/page.tsx:9:84)
    at (rsc)/./app/page.tsx (/project/sandbox/.next/server/app/page.js:162:1)
    at Function.__webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at async Promise.all (index 0)
digest: "2744214429"
 ⨯ createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (./app/page.tsx:9:84)
    at (rsc)/./app/page.tsx (/project/sandbox/.next/server/app/page.js:162:1)
    at Function.__webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at async Promise.all (index 0)
digest: "2744214429"
 ⨯ createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (./app/page.tsx:9:84)
    at (rsc)/./app/page.tsx (/project/sandbox/.next/server/app/page.js:162:1)
    at Function.__webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
digest: "1104297394"
createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/RendererContext.esm.js:18:73)
    at (rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/RendererContext.esm.js (/project/sandbox/.next/server/vendor-chunks/@griffel+react@1.5.25_react@18.3.1.js:170:1)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/makeStyles.esm.js:7:81)
    at (rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/makeStyles.esm.js (/project/sandbox/.next/server/vendor-chunks/@griffel+react@1.5.25_react@18.3.1.js:270:1)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/index.esm.js:23:76)
    at (rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/index.esm.js (/project/sandbox/.next/server/vendor-chunks/@griffel+react@1.5.25_react@18.3.1.js:230:1)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@fluentui+react-components@9.54.15_@types+react-dom@18.3.0_@types+react@18.3.5_react-dom@18.3_jgwnwapdklhjslg6kgd3ybekpy/node_modules/@fluentui/react-components/lib-commonjs/index.js:3080:16)
    at (rsc)/./node_modules/.pnpm/@fluentui+react-components@9.54.15_@types+react-dom@18.3.0_@types+react@18.3.5_react-dom@18.3_jgwnwapdklhjslg6kgd3ybekpy/node_modules/@fluentui/react-components/lib-commonjs/index.js (/project/sandbox/.next/server/vendor-chunks/@fluentui+react-components@9.54.15_@types+react-dom@18.3.0_@types+react@18.3.5_react-dom@18.3_jgwnwapdklhjslg6kgd3ybekpy.js:30:1)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(rsc)/./app/page.tsx:9:84)
    at (rsc)/./app/page.tsx (/project/sandbox/.next/server/app/page.js:162:1)
    at Function.__webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at async e7 (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:396658)
    at async tS (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:400214)
    at async tw (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:400775)
    at async tw (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:400906)
    at async tO (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:36:2320)
    at async /project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:36:2989 {
  digest: '1104297394'
}
 ⨯ createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/RendererContext.esm.js:18:73)
    at (rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/RendererContext.esm.js (/project/sandbox/.next/server/vendor-chunks/@griffel+react@1.5.25_react@18.3.1.js:170:1)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/makeStyles.esm.js:7:81)
    at (rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/makeStyles.esm.js (/project/sandbox/.next/server/vendor-chunks/@griffel+react@1.5.25_react@18.3.1.js:270:1)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/index.esm.js:23:76)
    at (rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/index.esm.js (/project/sandbox/.next/server/vendor-chunks/@griffel+react@1.5.25_react@18.3.1.js:230:1)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@fluentui+react-components@9.54.15_@types+react-dom@18.3.0_@types+react@18.3.5_react-dom@18.3_jgwnwapdklhjslg6kgd3ybekpy/node_modules/@fluentui/react-components/lib-commonjs/index.js:3080:16)
    at (rsc)/./node_modules/.pnpm/@fluentui+react-components@9.54.15_@types+react-dom@18.3.0_@types+react@18.3.5_react-dom@18.3_jgwnwapdklhjslg6kgd3ybekpy/node_modules/@fluentui/react-components/lib-commonjs/index.js (/project/sandbox/.next/server/vendor-chunks/@fluentui+react-components@9.54.15_@types+react-dom@18.3.0_@types+react@18.3.5_react-dom@18.3_jgwnwapdklhjslg6kgd3ybekpy.js:30:1)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(rsc)/./app/page.tsx:9:84)
    at (rsc)/./app/page.tsx (/project/sandbox/.next/server/app/page.js:162:1)
    at Function.__webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at async e7 (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:396658)
    at async tS (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:400214)
    at async tw (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:400775)
    at async tw (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:400906)
    at async tO (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:36:2320)
    at async /project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:36:2989 {
  digest: '1104297394',
  page: '/'
}
 GET / 500 in 193ms
 ⨯ createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (./app/page.tsx:9:84)
    at (rsc)/./app/page.tsx (/project/sandbox/.next/server/app/page.js:162:1)
    at Function.__webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at async Promise.all (index 0)
digest: "2744214429"
 ⨯ createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (./app/page.tsx:9:84)
    at (rsc)/./app/page.tsx (/project/sandbox/.next/server/app/page.js:162:1)
    at Function.__webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at async Promise.all (index 0)
digest: "2744214429"
 ⨯ createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (./app/page.tsx:9:84)
    at (rsc)/./app/page.tsx (/project/sandbox/.next/server/app/page.js:162:1)
    at Function.__webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
digest: "1104297394"
createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/RendererContext.esm.js:18:73)
    at (rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/RendererContext.esm.js (/project/sandbox/.next/server/vendor-chunks/@griffel+react@1.5.25_react@18.3.1.js:170:1)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/makeStyles.esm.js:7:81)
    at (rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/makeStyles.esm.js (/project/sandbox/.next/server/vendor-chunks/@griffel+react@1.5.25_react@18.3.1.js:270:1)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/index.esm.js:23:76)
    at (rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/index.esm.js (/project/sandbox/.next/server/vendor-chunks/@griffel+react@1.5.25_react@18.3.1.js:230:1)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@fluentui+react-components@9.54.15_@types+react-dom@18.3.0_@types+react@18.3.5_react-dom@18.3_jgwnwapdklhjslg6kgd3ybekpy/node_modules/@fluentui/react-components/lib-commonjs/index.js:3080:16)
    at (rsc)/./node_modules/.pnpm/@fluentui+react-components@9.54.15_@types+react-dom@18.3.0_@types+react@18.3.5_react-dom@18.3_jgwnwapdklhjslg6kgd3ybekpy/node_modules/@fluentui/react-components/lib-commonjs/index.js (/project/sandbox/.next/server/vendor-chunks/@fluentui+react-components@9.54.15_@types+react-dom@18.3.0_@types+react@18.3.5_react-dom@18.3_jgwnwapdklhjslg6kgd3ybekpy.js:30:1)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(rsc)/./app/page.tsx:9:84)
    at (rsc)/./app/page.tsx (/project/sandbox/.next/server/app/page.js:162:1)
    at Function.__webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at async e7 (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:396658)
    at async tS (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:400214)
    at async tw (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:400775)
    at async tw (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:400906)
    at async tO (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:36:2320)
    at async /project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:36:2989 {
  digest: '1104297394'
}
 ⨯ createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/RendererContext.esm.js:18:73)
    at (rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/RendererContext.esm.js (/project/sandbox/.next/server/vendor-chunks/@griffel+react@1.5.25_react@18.3.1.js:170:1)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/makeStyles.esm.js:7:81)
    at (rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/makeStyles.esm.js (/project/sandbox/.next/server/vendor-chunks/@griffel+react@1.5.25_react@18.3.1.js:270:1)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/index.esm.js:23:76)
    at (rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/index.esm.js (/project/sandbox/.next/server/vendor-chunks/@griffel+react@1.5.25_react@18.3.1.js:230:1)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@fluentui+react-components@9.54.15_@types+react-dom@18.3.0_@types+react@18.3.5_react-dom@18.3_jgwnwapdklhjslg6kgd3ybekpy/node_modules/@fluentui/react-components/lib-commonjs/index.js:3080:16)
    at (rsc)/./node_modules/.pnpm/@fluentui+react-components@9.54.15_@types+react-dom@18.3.0_@types+react@18.3.5_react-dom@18.3_jgwnwapdklhjslg6kgd3ybekpy/node_modules/@fluentui/react-components/lib-commonjs/index.js (/project/sandbox/.next/server/vendor-chunks/@fluentui+react-components@9.54.15_@types+react-dom@18.3.0_@types+react@18.3.5_react-dom@18.3_jgwnwapdklhjslg6kgd3ybekpy.js:30:1)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(rsc)/./app/page.tsx:9:84)
    at (rsc)/./app/page.tsx (/project/sandbox/.next/server/app/page.js:162:1)
    at Function.__webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at async e7 (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:396658)
    at async tS (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:400214)
    at async tw (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:400775)
    at async tw (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:400906)
    at async tO (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:36:2320)
    at async /project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:36:2989 {
  digest: '1104297394',
  page: '/'
}
 GET / 500 in 81ms
 ⨯ createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (./app/page.tsx:9:84)
    at (rsc)/./app/page.tsx (/project/sandbox/.next/server/app/page.js:162:1)
    at Function.__webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at async Promise.all (index 0)
digest: "1650754739"
 ⨯ createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (./app/page.tsx:9:84)
    at (rsc)/./app/page.tsx (/project/sandbox/.next/server/app/page.js:162:1)
    at Function.__webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at async Promise.all (index 0)
digest: "1650754739"
 ⨯ createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (./app/page.tsx:9:84)
    at (rsc)/./app/page.tsx (/project/sandbox/.next/server/app/page.js:162:1)
    at Function.__webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
digest: "1104297394"
createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/RendererContext.esm.js:18:73)
    at (rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/RendererContext.esm.js (/project/sandbox/.next/server/vendor-chunks/@griffel+react@1.5.25_react@18.3.1.js:170:1)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/makeStyles.esm.js:7:81)
    at (rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/makeStyles.esm.js (/project/sandbox/.next/server/vendor-chunks/@griffel+react@1.5.25_react@18.3.1.js:270:1)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/index.esm.js:23:76)
    at (rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/index.esm.js (/project/sandbox/.next/server/vendor-chunks/@griffel+react@1.5.25_react@18.3.1.js:230:1)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@fluentui+react-components@9.54.15_@types+react-dom@18.3.0_@types+react@18.3.5_react-dom@18.3_jgwnwapdklhjslg6kgd3ybekpy/node_modules/@fluentui/react-components/lib-commonjs/index.js:3080:16)
    at (rsc)/./node_modules/.pnpm/@fluentui+react-components@9.54.15_@types+react-dom@18.3.0_@types+react@18.3.5_react-dom@18.3_jgwnwapdklhjslg6kgd3ybekpy/node_modules/@fluentui/react-components/lib-commonjs/index.js (/project/sandbox/.next/server/vendor-chunks/@fluentui+react-components@9.54.15_@types+react-dom@18.3.0_@types+react@18.3.5_react-dom@18.3_jgwnwapdklhjslg6kgd3ybekpy.js:30:1)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(rsc)/./app/page.tsx:9:84)
    at (rsc)/./app/page.tsx (/project/sandbox/.next/server/app/page.js:162:1)
    at Function.__webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at async e7 (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:396658)
    at async tS (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:400214)
    at async tw (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:400775)
    at async tw (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:400906)
    at async tO (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:36:2320)
    at async /project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:36:2989 {
  digest: '1104297394'
}
 ⨯ createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/RendererContext.esm.js:18:73)
    at (rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/RendererContext.esm.js (/project/sandbox/.next/server/vendor-chunks/@griffel+react@1.5.25_react@18.3.1.js:170:1)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/makeStyles.esm.js:7:81)
    at (rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/makeStyles.esm.js (/project/sandbox/.next/server/vendor-chunks/@griffel+react@1.5.25_react@18.3.1.js:270:1)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/index.esm.js:23:76)
    at (rsc)/./node_modules/.pnpm/@griffel+react@1.5.25_react@18.3.1/node_modules/@griffel/react/index.esm.js (/project/sandbox/.next/server/vendor-chunks/@griffel+react@1.5.25_react@18.3.1.js:230:1)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@fluentui+react-components@9.54.15_@types+react-dom@18.3.0_@types+react@18.3.5_react-dom@18.3_jgwnwapdklhjslg6kgd3ybekpy/node_modules/@fluentui/react-components/lib-commonjs/index.js:3080:16)
    at (rsc)/./node_modules/.pnpm/@fluentui+react-components@9.54.15_@types+react-dom@18.3.0_@types+react@18.3.5_react-dom@18.3_jgwnwapdklhjslg6kgd3ybekpy/node_modules/@fluentui/react-components/lib-commonjs/index.js (/project/sandbox/.next/server/vendor-chunks/@fluentui+react-components@9.54.15_@types+react-dom@18.3.0_@types+react@18.3.5_react-dom@18.3_jgwnwapdklhjslg6kgd3ybekpy.js:30:1)
    at __webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(rsc)/./app/page.tsx:9:84)
    at (rsc)/./app/page.tsx (/project/sandbox/.next/server/app/page.js:162:1)
    at Function.__webpack_require__ (/project/sandbox/.next/server/webpack-runtime.js:33:42)
    at async e7 (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:396658)
    at async tS (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:400214)
    at async tw (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:400775)
    at async tw (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:400906)
    at async tO (/project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:36:2320)
    at async /project/sandbox/node_modules/.pnpm/next@14.2.11_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:36:2989 {
  digest: '1104297394',
  page: '/'
}

Requested priority

Blocking

Products/sites affected

No response

Are you willing to submit a PR to fix?

no

Validations

mainframev commented 1 month ago

@zailic hi 👋🏻

Try to add transpilePackages: ["@fluentui/react-components"] as it mentioned here

zailic commented 1 month ago

hi @mainframev, yeesss it worked, thanks! I really appreciate your quick feedback on this. I guess this issue it could be closed...but (for a frictionless developer experience) I wonder if it wouldn't be better to keep this issue open until the documentation is updated as well?

mainframev commented 1 month ago

@sopranopillow 👋🏻 , can you confirm that suggested approach is ok?

I see that #30766 is still opened and with transpilePackages it works even without the plugin, so not sure if it's correct. I can close this issue as duplicate of the mentioned above.

zailic commented 1 month ago

@mainframev, actually the issue is still present if i'm going further and trying to use styles. I've updated the reproduction sample. Could you please take a look?

mainframev commented 1 month ago

@zailic You can't use makeStyles directly in the server component, you would have to put it inside a separate client-component and import inside the page. Or you can enable 'use client' for page, but I assume that's not what you want. So something like this will work:

// page.tsx
import * as React from "react";
import { Button } from "@fluentui/react-components";
import Main from "./Main";

export default function Home() {
  return (
    <Main>
      <Button>Hello everyone</Button>
    </Main>
  );
}

// Main.tsx
"use client";

import { makeStyles } from "@fluentui/react-components";

const useStyles = makeStyles({
  main: {
    height: "100vh",
  },
});

export default function Main({ children }) {
  const styles = useStyles();
  return <main className={styles.main}>{children}</main>;
}
microsoft-github-policy-service[bot] commented 1 month ago

This issue has been automatically marked as stale because it has marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your contributions to Fluent UI!