`You're importing a component that imports client-only. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.`
`'client-only' cannot be imported from a Server Component module`
'next/headers' cannot be imported from a Client Component module
> 1 | import { cookies } from 'next/headers'
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 |
3 | export default function Page() {
4 | return <p>hello world</p>
You're importing a component that needs "next/headers". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components
It only works in a Server Component which is not supported in the pages/ directory.
@@ -81,7 +79,8 @@ describe('Error Overlay for server components compiler errors in pages', () => {
)
).toMatchInlineSnapshot(`
"./components/Comp.js
╰─▶ × Error: x You're importing a component that needs "next/headers". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components
╰─▶ × Error: x 'next/headers' cannot be imported from a Client Component module.
│ | That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components
│ |
│
│ ,-[1:1]
...
...
@@ -96,7 +95,8 @@ describe('Error Overlay for server components compiler errors in pages', () => {
Error: x You're importing a component that needs "next/headers". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components
Error: x 'next/headers' cannot be imported from a Client Component module.
| That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components
|
,-[1:1]
...
...
@@ -130,22 +130,21 @@ describe('Error Overlay for server components compiler errors in pages', () => {
'server-only' cannot be imported from a Client Component module
> 1 | import 'server-only'
| ^^^^^^^^^^^^^^^^^^^^
2 |
3 | export default function Page() {
4 | return 'hello world'
You're importing a component that needs "server-only". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components
Modules use import 'server-only' to flag they shouldn't be used from Client Components.
It only works in a Server Component which is not supported in the pages/ directory.
@@ -164,7 +163,8 @@ describe('Error Overlay for server components compiler errors in pages', () => {
)
).toMatchInlineSnapshot(`
"./components/Comp.js
╰─▶ × Error: x You're importing a component that needs "server-only". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components
╰─▶ × Error: x 'server-only' cannot be imported from a Client Component module.
│ | That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components
│ |
│
│ ,-[1:1]
...
...
@@ -183,7 +183,8 @@ describe('Error Overlay for server components compiler errors in pages', () => {
)
).toMatchInlineSnapshot(`
"./components/Comp.js
Error: x You're importing a component that needs "server-only". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components
Error: x 'server-only' cannot be imported from a Client Component module.
| That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components
|
,-[1:1]
...
...
@@ -215,9 +216,6 @@ describe('Error Overlay for server components compiler errors in pages', () => {
@@ -230,7 +228,8 @@ describe('Error Overlay for server components compiler errors in pages', () => {
3 | export default function Page() {
4 | return 'hello world'
You're importing a component that needs "after". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components
'after' cannot be imported from a Client Component module.
That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components
Import traces:
Browser:
...
...
@@ -249,7 +248,8 @@ describe('Error Overlay for server components compiler errors in pages', () => {
)
).toMatchInlineSnapshot(`
"./components/Comp.js
╰─▶ × Error: x You're importing a component that needs "after". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components
╰─▶ × Error: x 'after' cannot be imported from a Client Component module.
│ | That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components
│ |
│
│ ,-[1:1]
...
...
@@ -268,7 +268,8 @@ describe('Error Overlay for server components compiler errors in pages', () => {
)
).toMatchInlineSnapshot(`
"./components/Comp.js
Error: x You're importing a component that needs "after". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components
Error: x 'after' cannot be imported from a Client Component module.
| That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components
|
,-[1:1]
...
...
@@ -309,22 +310,20 @@ describe('Error Overlay for server components compiler errors in pages', () => {
'next/root-params' cannot be imported from a Client Component module
> 1 | import { foo } from 'next/root-params'
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 |
3 | export default function Page() {
4 | return 'hello world'
You're importing a component that needs "next/root-params". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components
It only works in a Server Component which is not supported in the pages/ directory.
@@ -343,7 +342,8 @@ describe('Error Overlay for server components compiler errors in pages', () => {
)
).toMatchInlineSnapshot(`
"./components/Comp.js
╰─▶ × Error: x You're importing a component that needs "next/root-params". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components
╰─▶ × Error: x 'next/root-params' cannot be imported from a Client Component module.
│ | That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components
│ |
│
│ ,-[1:1]
...
...
@@ -362,7 +362,8 @@ describe('Error Overlay for server components compiler errors in pages', () => {
)
).toMatchInlineSnapshot(`
"./components/Comp.js
Error: x You're importing a component that needs "next/root-params". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components
Error: x 'next/root-params' cannot be imported from a Client Component module.
| That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components
|
,-[1:1]
...
...
@@ -400,8 +401,8 @@ describe('Error Overlay for server components compiler errors in pages', () => {