-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Versions
@prismicio/next: v1.3.4next: v13.4.19- node: v16.17.0, v18.17.1
Reproduction
Additional Details
{
"name": "prismic-test",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"slicemachine": "start-slicemachine"
},
"dependencies": {
"@prismicio/client": "^7.2.0",
"@prismicio/next": "^1.3.4",
"@prismicio/react": "^2.7.1",
"autoprefixer": "10.4.15",
"eslint": "8.48.0",
"eslint-config-next": "13.4.19",
"next": "^13.4.19",
"postcss": "8.4.29",
"react": "18.2.0",
"react-dom": "18.2.0",
"tailwindcss": "3.3.3"
}
}
Steps to reproduce
- Run
npx create-next-app@latestandnpx @slicemachine/init@latestwith App Router enabled - In the
next.config.jsfile add the following to thenextConfig
const nextConfig = {
transpilePackages: ["@prismicio/client", "@prismicio/next"]
}
- Create a component as follows
"use client"
import { PrismicNextLink } from "@prismicio/next"
export default function StyledLink() {
return <PrismicNextLink />
}
- Import and render the new component into a
page.jsin yourappdirectory - Attempt to navigate to the page with component included and see a Server Component error
What is expected?
PrismicNextLink will render the same with or without the "use client" directive, as it does so when not transpiling the packages using NextJS configuration
What is actually happening?
The new component throws the following fatal error
ReactServerComponentsError:
You're importing a component that needs next/headers. That only works in a Server Component but one of its parents is marked with "use client", so it's a Client Component.
Learn more: https://nextjs.org/docs/getting-started/react-essentials
1 | import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2 | import Script from "next/script";
3 | import { draftMode } from "next/headers";
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4 | import { PrismicPreviewClient } from "./PrismicPreviewClient.js";
5 | import { getToolbarSrc } from './_node_modules/@prismicio/client/dist/getToolbarSrc.js';
6 | function PrismicPreview({ repositoryName, children, ...props }) {
`----
One of these is marked as a client entry with "use client":
./node_modules\@prismicio\next\dist\PrismicPreview.js
./node_modules\@prismicio\next\dist\index.js
./components\StyledLink.js
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working