Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't render rich text in nextjs server component #175

Closed
justin-hackin opened this issue Feb 9, 2023 · 1 comment
Closed

Can't render rich text in nextjs server component #175

justin-hackin opened this issue Feb 9, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@justin-hackin
Copy link

justin-hackin commented Feb 9, 2023

Previously, I was using

"prismic-javascript": "3.0.2",
"prismic-reactjs": "1.3.4",

to render rich text fields in a next.js server component and I decided to upgrade. I don't need slices, I just want to get my data into a single component and pass it down through props. Previously I was able to render them just fine using RichText.

I migrated to

    "@prismicio/client": "6.7.3",
    "@prismicio/helpers": "2.3.9",
    "@prismicio/react": "2.5.1",

Now the app barks at me for trying to use a context in a server component 😖 with

TypeError: 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

Is it possible to use this component without a context in a server component or do I have to revert to the old versions of this library?

@justin-hackin justin-hackin added the bug Something isn't working label Feb 9, 2023
@justin-hackin justin-hackin changed the title Can't render rich text in server component Can't render rich text in nextjs server component Feb 9, 2023
@angeloashmore
Copy link
Member

Hi @justin-hackin, React Server Components and Next.js' App Router is a significant change from pre-Next.js 13.4. The update required changes in how <PrismicRichText> works and, in some cases, how it is used.

I just published v2.6.0 which now supports Server Components. See #178 for more details.

You should be able to use <PrismicRichText> in Server Components now. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants