Skip to content

App directory support with servercomponents #442

Closed
@joellp

Description

@joellp

Hello! I'm trying to get next-drupal working with the new app directory of Next.js. This does work for client components, but I cannot get it working for ServerComponents.

import { drupal } from "lib/drupal"
import { NodeArticle } from "components/node--article"
import { DrupalNode } from 'next-drupal';

const Article = async () => {
  // This requires "use client"
  const drupalContent = await drupal.getResource<DrupalNode>('node--article', 'bb601c1a-6e1f-4e09-9b42-ef07136963f4')
 
  return (
    drupalContent ? <NodeArticle node={drupalContent} />: <h1>Hi</h1>
  );  
}

export default Article;

When fetching resources a call to createContext is made, which requires me to use a client component. Is there a way to use this in Server Components?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions